net.sf.hermesftp.streams
Class RecordInputStream

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

public class RecordInputStream
extends java.io.InputStream
implements RecordReadSupport

In a record structured file EOR and EOF will each be indicated by a two-byte control code. The first byte of the control code will be all ones, the escape character. The second byte will have the low order bit on and zeros elsewhere for EOR and the second low order bit on for EOF; that is, the byte will have value 1 for EOR and value 2 for EOF. EOR and EOF may be indicated together on the last byte transmitted by turning both low order bits on (i.e., the value 3). If a byte of all ones was intended to be sent as data, it should be repeated in the second byte of the control code.

Author:
Lars Behnke

Constructor Summary
RecordInputStream(java.io.InputStream is)
          Constructor.
RecordInputStream(java.io.InputStream is, byte[] eorMarker)
          Constructor.
 
Method Summary
 void close()
          
 int read()
          
 byte[] readRecord()
          Reads a complete record, excluding the end marker.
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecordInputStream

public RecordInputStream(java.io.InputStream is)
Constructor.

Parameters:
is - The input stream.

RecordInputStream

public RecordInputStream(java.io.InputStream is,
                         byte[] eorMarker)
Constructor.

Parameters:
is - The input stream.
eorMarker - The byte sequence the EOR marker is translated to (e.g. line break).
Method Detail

read

public int read()
         throws java.io.IOException

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

readRecord

public byte[] readRecord()
                  throws java.io.IOException
Reads a complete record, excluding the end marker.

Specified by:
readRecord in interface RecordReadSupport
Returns:
The record without EOR/EOF marker.
Throws:
java.io.IOException - If something goes wrong.

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


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