public class RandomAccessFileInputStream
extends java.io.InputStream
RandomAccessFile starting at its current position.| Modifier and Type | Field and Description |
|---|---|
private boolean |
closeOnClose |
private java.io.RandomAccessFile |
randomAccessFile |
| Constructor and Description |
|---|
RandomAccessFileInputStream(java.io.RandomAccessFile file)
Constructs a new instance configured to leave the underlying file open when this stream is closed.
|
RandomAccessFileInputStream(java.io.RandomAccessFile file,
boolean closeOnClose)
Constructs a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream.
|
long |
availableLong()
Returns the number of bytes that can be read (or skipped over) from this input stream.
|
void |
close() |
java.io.RandomAccessFile |
getRandomAccessFile()
Gets the underlying file.
|
boolean |
isCloseOnClose()
Returns whether to close the underlying file when this stream is closed.
|
int |
read() |
int |
read(byte[] bytes) |
int |
read(byte[] bytes,
int offset,
int length) |
private void |
seek(long position)
Delegates to the underlying file.
|
long |
skip(long skipCount) |
private final boolean closeOnClose
private final java.io.RandomAccessFile randomAccessFile
public RandomAccessFileInputStream(java.io.RandomAccessFile file)
file - The file to stream.public RandomAccessFileInputStream(java.io.RandomAccessFile file,
boolean closeOnClose)
file - The file to stream.closeOnClose - Whether to close the underlying file when this stream is closed.public int available()
throws java.io.IOException
Integer.MAX_VALUE bytes available, return Integer.MAX_VALUE.available in class java.io.InputStreamjava.io.IOException - If an I/O error occurs.public long availableLong()
throws java.io.IOException
java.io.IOException - If an I/O error occurs.public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreamjava.io.IOExceptionpublic java.io.RandomAccessFile getRandomAccessFile()
public boolean isCloseOnClose()
public int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic int read(byte[] bytes)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic int read(byte[] bytes,
int offset,
int length)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionprivate void seek(long position)
throws java.io.IOException
position - See RandomAccessFile.seek(long).java.io.IOException - See RandomAccessFile.seek(long).RandomAccessFile.seek(long)public long skip(long skipCount)
throws java.io.IOException
skip in class java.io.InputStreamjava.io.IOException