Class ImportFileInputStream
java.lang.Object
java.io.InputStream
org.apache.derby.impl.load.ImportFileInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
An InputStream, which can stream data from a file, starting from
any offset in the file. This stream operates on top of a
RandomAccessFile object. This class overrides InputStream methods to
read from the given RandomAccessFile and provides an addtional method
seek(..) to position the stream at offset in the file.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate aImportFileInputStreamobject for the given file. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of bytes that can be read from this stream.voidclose()Closes this input stream and releases any associated resourcesintread()Reads a byte of data from this input stream.intread(byte[] buf, int offset, int length) Reads up tolengthbytes of data from this input stream into given array.(package private) voidseek(long offset) Sets the file offset at which the next read will occur.Methods inherited from class InputStream
mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
raf
-
currentPosition
private long currentPosition -
fileLength
private long fileLength
-
-
Constructor Details
-
ImportFileInputStream
ImportFileInputStream(RandomAccessFile raf) throws IOException Create aImportFileInputStreamobject for the given file.- Parameters:
raf- file the stream reads from.- Throws:
IOException- if any I/O error occurs.
-
-
Method Details
-
seek
Sets the file offset at which the next read will occur.- Parameters:
offset- byte offset in the file.- Throws:
IOException- if an I/O error occurs.
-
read
Reads a byte of data from this input stream.- Specified by:
readin classInputStream- Throws:
IOException- if an I/O error occurs.
-
read
Reads up tolengthbytes of data from this input stream into given array. This method blocks until some input is available.- Overrides:
readin classInputStream- Parameters:
buf- the buffer into which the data is read.offset- the start offset of the data.length- the maximum number of bytes read.- Returns:
- the total number of bytes read into the buffer, or
-1if there is no more data because the end of the file has been reached. - Throws:
IOException- if an I/O error occurs.
-
available
Returns the number of bytes that can be read from this stream.- Overrides:
availablein classInputStream- Returns:
- the number of bytes that can be read from this stream.
- Throws:
IOException- if an I/O error occurs.
-
close
Closes this input stream and releases any associated resources- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException- if an I/O error occurs.
-