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 SummaryNested Classes
- 
Constructor SummaryConstructorsConstructorDescriptionDeprecated.RandomAccessFileInputStream(RandomAccessFile file, boolean propagateClose) Deprecated.
- 
Method SummaryModifier and TypeMethodDescriptionintGets an estimate of the number of bytes that can be read (or skipped over) from this input stream.longGets the number of bytes that can be read (or skipped over) from this input stream.builder()Constructs a newRandomAccessFileInputStream.Builder.voidclose()longcopy(long pos, long size, OutputStream os) Copies our bytes from the given starting position for a size to the output stream.Gets the underlying file.booleanTests whether to close the underlying file when this stream is closed, defaults to false for compatibility.intread()intread(byte[] bytes) intread(byte[] bytes, int offset, int length) longskip(long skipCount) Methods inherited from class org.apache.commons.io.input.AbstractInputStreamisClosed, setClosedMethods inherited from class java.io.InputStreammark, markSupported, reset
- 
Constructor Details- 
RandomAccessFileInputStreamDeprecated.Constructs a new instance configured to leave the underlying file open when this stream is closed.- Parameters:
- file- The file to stream.
 
- 
RandomAccessFileInputStreamDeprecated.Constructs a new instance.- Parameters:
- file- The file to stream.
- propagateClose- Whether to close the underlying file when this stream is closed.
 
 
- 
- 
Method Details- 
builderConstructs a newRandomAccessFileInputStream.Builder.- Returns:
- a new RandomAccessFileInputStream.Builder.
- Since:
- 2.12.0
 
- 
availableGets an estimate of the number of bytes that can be read (or skipped over) from this input stream.If there are more than Integer.MAX_VALUEbytes available, returnInteger.MAX_VALUE.- Overrides:
- availablein class- InputStream
- Returns:
- An estimate of the number of bytes that can be read.
- Throws:
- IOException- If an I/O error occurs.
 
- 
availableLongGets 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:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- AbstractInputStream
- Throws:
- IOException
 
- 
copyCopies our bytes from the given starting position for a size to the output stream.- Parameters:
- pos- Where to start copying. The offset position, measured in bytes from the beginning of the file, at which to set the file pointer.
- size- The number of bytes to copy.
- os- Where to copy.
- Returns:
- The number of bytes copied..
- Throws:
- IOException- if- posis less than- 0or if an I/O error occurs.
- Since:
- 2.19.0
 
- 
getRandomAccessFileGets the underlying file.- Returns:
- the underlying file.
 
- 
isCloseOnCloseTests whether to close the underlying file when this stream is closed, defaults to false for compatibility.- Returns:
- Whether to close the underlying file when this stream is closed.
 
- 
read- Specified by:
- readin class- InputStream
- Throws:
- IOException
 
- 
read- Overrides:
- readin class- InputStream
- Throws:
- IOException
 
- 
read- Overrides:
- readin class- InputStream
- Throws:
- IOException
 
- 
skip- Overrides:
- skipin class- InputStream
- Throws:
- IOException
 
 
- 
builder(),RandomAccessFileInputStream.Builder, andRandomAccessFileInputStream.Builder.get()