|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
org.fuin.utils4j.RandomAccessFileInputStream
public final class RandomAccessFileInputStream
A random access based file input stream. The readlimit argument
of the mark(int) method is ignored (there is no limit).
| Constructor Summary | |
|---|---|
RandomAccessFileInputStream(java.io.File file,
java.lang.String mode)
Constructor with file. |
|
RandomAccessFileInputStream(RandomAccessFileInputStream in)
Constructor with input stream. |
|
RandomAccessFileInputStream(RandomAccessFileOutputStream out)
Constructor with output stream. |
|
| Method Summary | |
|---|---|
int |
available()
|
void |
close()
|
long |
fileSize()
Returns the size of the underlying file. |
java.nio.channels.FileChannel |
getChannel()
Returns the channel used by the random access file. |
java.nio.channels.FileLock |
lock(int tryLockMax,
long tryWaitMillis)
Lock the file. |
void |
mark(int readlimit)
|
boolean |
markSupported()
|
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
void |
reset()
|
void |
seek(long pos)
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs. |
long |
skip(long n)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RandomAccessFileInputStream(java.io.File file,
java.lang.String mode)
throws java.io.FileNotFoundException
file - File the stream operates on - Cannot be null.mode - Access mode, as described in RandomAccessFile -
Cannot be null.
java.io.FileNotFoundException - If the mode is "r" but the given file object does not denote
an existing regular file, or if the mode begins with "rw" but
the given file object does not denote an existing, writable
regular file and a new regular file of that name cannot be
created, or if some other error occurs while opening or
creating the file.public RandomAccessFileInputStream(RandomAccessFileInputStream in)
RandomAccessFile with the argument. Be aware that closing
this stream will also close the file used by the argument!
in - The RandomAccessFile instance from this argument
will be used - Cannot be null.public RandomAccessFileInputStream(RandomAccessFileOutputStream out)
RandomAccessFile with the argument. Be aware that closing
this stream will also close the file used by the argument!
out - The RandomAccessFile instance from this argument
will be used - Cannot be null.| Method Detail |
|---|
public final int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException
public final int read(byte[] b)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException
public final int read(byte[] b,
int off,
int len)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException
public final long skip(long n)
throws java.io.IOException
skip in class java.io.InputStreamjava.io.IOException
public final long fileSize()
throws java.io.IOException
java.io.IOException - IOException if an I/O error occurs.
public final int available()
throws java.io.IOException
available in class java.io.InputStreamjava.io.IOException
public final void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.InputStreamjava.io.IOExceptionpublic void mark(int readlimit)
mark in class java.io.InputStream
public final void reset()
throws java.io.IOException
reset in class java.io.InputStreamjava.io.IOExceptionpublic final boolean markSupported()
markSupported in class java.io.InputStreampublic final java.nio.channels.FileChannel getChannel()
public final void seek(long pos)
throws java.io.IOException
pos - the offset position, measured in bytes from the beginning of
the file, at which to set the file pointer.
java.io.IOException - if pos is less than 0 or if an
I/O error occurs.
public final java.nio.channels.FileLock lock(int tryLockMax,
long tryWaitMillis)
throws LockingFailedException
tryLockMax - Number of tries to lock before throwing an exception.tryWaitMillis - Milliseconds to sleep between retries.
LockingFailedException - Locking the file failed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||