Package org.apache.derby.impl.load
Class ImportFileInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.derby.impl.load.ImportFileInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
class ImportFileInputStream extends java.io.InputStreamAn 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 methodseek(..)to position the stream at offset in the file.
-
-
Field Summary
Fields Modifier and Type Field Description private longcurrentPositionprivate longfileLengthprivate java.io.RandomAccessFileraf
-
Constructor Summary
Constructors Constructor Description ImportFileInputStream(java.io.RandomAccessFile raf)Create aImportFileInputStreamobject for the given file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Returns 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.
-
-
-
Method Detail
-
seek
void seek(long offset) throws java.io.IOException
Sets the file offset at which the next read will occur.- Parameters:
offset- byte offset in the file.- Throws:
java.io.IOException- if an I/O error occurs.
-
read
public int read() throws java.io.IOExceptionReads a byte of data from this input stream.- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException- if an I/O error occurs.
-
read
public int read(byte[] buf, int offset, int length) throws java.io.IOExceptionReads up tolengthbytes of data from this input stream into given array. This method blocks until some input is available.- Overrides:
readin classjava.io.InputStream- 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:
java.io.IOException- if an I/O error occurs.
-
available
public int available() throws java.io.IOExceptionReturns the number of bytes that can be read from this stream.- Overrides:
availablein classjava.io.InputStream- Returns:
- the number of bytes that can be read from this stream.
- Throws:
java.io.IOException- if an I/O error occurs.
-
close
public void close() throws java.io.IOExceptionCloses this input stream and releases any associated resources- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException- if an I/O error occurs.
-
-