public final class RandomAccessFileInputStream
extends java.io.InputStream
readlimit
argument
of the mark(int)
method is ignored (there is no limit).Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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) |
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
.public final int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public final int read(byte[] b) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public final int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public final long skip(long n) throws java.io.IOException
skip
in class java.io.InputStream
java.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.InputStream
java.io.IOException
public final void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
public void mark(int readlimit)
mark
in class java.io.InputStream
public final void reset() throws java.io.IOException
reset
in class java.io.InputStream
java.io.IOException
public final boolean markSupported()
markSupported
in class java.io.InputStream
public 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.