Package org.apache.commons.io.input
Class RandomAccessFileInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.io.input.AbstractInputStream
org.apache.commons.io.input.RandomAccessFileInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
Streams data from a
RandomAccessFile
starting at its current position.
To build an instance, use RandomAccessFileInputStream.Builder
.
- Since:
- 2.8.0
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionDeprecated.RandomAccessFileInputStream
(RandomAccessFile file, boolean propagateClose) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets an estimate of the number of bytes that can be read (or skipped over) from this input stream.long
Gets the number of bytes that can be read (or skipped over) from this input stream.builder()
Constructs a newRandomAccessFileInputStream.Builder
.void
close()
Gets the underlying file.boolean
Tests 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) long
skip
(long skipCount) Methods inherited from class org.apache.commons.io.input.AbstractInputStream
isClosed, setClosed
Methods inherited from class java.io.InputStream
mark, markSupported, reset
-
Constructor Details
-
RandomAccessFileInputStream
Deprecated.Constructs a new instance configured to leave the underlying file open when this stream is closed.- Parameters:
file
- The file to stream.
-
RandomAccessFileInputStream
Deprecated.Constructs a new instance.- Parameters:
file
- The file to stream.propagateClose
- Whether to close the underlying file when this stream is closed.
-
-
Method Details
-
builder
Constructs a newRandomAccessFileInputStream.Builder
.- Returns:
- a new
RandomAccessFileInputStream.Builder
. - Since:
- 2.12.0
-
available
Gets an estimate of the number of bytes that can be read (or skipped over) from this input stream. If there are more thanInteger.MAX_VALUE
bytes available, returnInteger.MAX_VALUE
.- Overrides:
available
in classInputStream
- Returns:
- An estimate of the number of bytes that can be read.
- Throws:
IOException
- If an I/O error occurs.
-
availableLong
Gets the number of bytes that can be read (or skipped over) from this input stream.- Returns:
- The number of bytes that can be read.
- Throws:
IOException
- If an I/O error occurs.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classAbstractInputStream
- Throws:
IOException
-
getRandomAccessFile
Gets the underlying file.- Returns:
- the underlying file.
-
isCloseOnClose
Tests whether to close the underlying file when this stream is closed.- Returns:
- Whether to close the underlying file when this stream is closed.
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
builder()
,RandomAccessFileInputStream.Builder
, andRandomAccessFileInputStream.Builder.get()