|
||||||||||
| 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(File file,
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. |
FileChannel |
getChannel()
Returns the channel used by the random access file. |
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(File file,
String mode)
throws FileNotFoundException
file - File the stream operates on - Cannot be null.mode - Access mode, as described in RandomAccessFile -
Cannot be null.
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 IOException
read in class InputStreamIOException
public final int read(byte[] b)
throws IOException
read in class InputStreamIOException
public final int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOException
public final long skip(long n)
throws IOException
skip in class InputStreamIOException
public final long fileSize()
throws IOException
IOException - IOException if an I/O error occurs.
public final int available()
throws IOException
available in class InputStreamIOException
public final void close()
throws IOException
close in interface Closeableclose in class InputStreamIOExceptionpublic void mark(int readlimit)
mark in class InputStream
public final void reset()
throws IOException
reset in class InputStreamIOExceptionpublic final boolean markSupported()
markSupported in class InputStreampublic final FileChannel getChannel()
public final void seek(long pos)
throws IOException
pos - the offset position, measured in bytes from the beginning of
the file, at which to set the file pointer.
IOException - if pos is less than 0 or if an
I/O error occurs.
public final 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 | |||||||||