org.apache.derby.impl.load
Class ImportFileInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.derby.impl.load.ImportFileInputStream
All Implemented Interfaces:
java.io.Closeable

 class ImportFileInputStream
extends java.io.InputStream

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
private  long currentPosition
           
private  long fileLength
           
private  java.io.RandomAccessFile raf
           
 
Constructor Summary
ImportFileInputStream(java.io.RandomAccessFile raf)
          Create a ImportFileInputStream object for the given file.
 
Method Summary
 int available()
          Returns the number of bytes that can be read from this stream.
 void close()
          Closes this input stream and releases any associated resources
 int read()
          Reads a byte of data from this input stream.
 int read(byte[] buf, int offset, int length)
          Reads up to length bytes of data from this input stream into given array.
(package private)  void seek(long offset)
          Sets the file offset at which the next read will occur.
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

raf

private java.io.RandomAccessFile raf

currentPosition

private long currentPosition

fileLength

private long fileLength
Constructor Detail

ImportFileInputStream

ImportFileInputStream(java.io.RandomAccessFile raf)
                throws java.io.IOException
Create a ImportFileInputStream object for the given file.

Parameters:
raf - file the stream reads from.
Throws:
java.io.IOException - if any I/O error occurs.
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.IOException
Reads a byte of data from this input stream.

Specified by:
read in class java.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.IOException
Reads up to length bytes of data from this input stream into given array. This method blocks until some input is available.

Overrides:
read in class java.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 -1 if 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.IOException
Returns the number of bytes that can be read from this stream.

Overrides:
available in class java.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.IOException
Closes this input stream and releases any associated resources

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException - if an I/O error occurs.

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.