net.sf.hermesftp.streams
Class RafInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by net.sf.hermesftp.streams.RafInputStream
All Implemented Interfaces:
java.io.Closeable, RecordReadSupport

public class RafInputStream
extends java.io.InputStream
implements RecordReadSupport

Wrapper class for reading a RandomAccessFile through the InputStream abstraction.

Author:
Lars Behnke

Constructor Summary
RafInputStream(java.io.File file)
          Constructor.
RafInputStream(java.io.File file, long offset)
          Constructor.
 
Method Summary
 void close()
          
 int read()
          
 int read(byte[] b)
          
 int read(byte[] b, int off, int len)
          
 byte[] readRecord()
          Reads a whole record without delimiters.
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RafInputStream

public RafInputStream(java.io.File file)
Constructor.

Parameters:
file - The input file.

RafInputStream

public RafInputStream(java.io.File file,
                      long offset)
Constructor.

Parameters:
file - The input file.
offset - The number of bytes to be skipped when reading the file.
Method Detail

read

public int read()
         throws java.io.IOException

Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException

readRecord

public byte[] readRecord()
                  throws java.io.IOException
Reads a whole record without delimiters.

Specified by:
readRecord in interface RecordReadSupport
Returns:
The record.
Throws:
java.io.IOException - Throws if reading fails.


Copyright © 2005-2007 Lars Behnke. All Rights Reserved.