com.ibm.jzos
Class RDWInputRecordStream

java.lang.Object
  extended by com.ibm.jzos.RDWInputRecordStream

public class RDWInputRecordStream
extends java.lang.Object

This class is a wrapper that returns RDW delineated records from an InputStream.

For example usage, see the sample class: com.ibm.jzos.sample.dfsort.DfSortVariableDatasetToJava


Constructor Summary
RDWInputRecordStream(java.io.InputStream is)
          Construct an instance of RDWInputRecordStream.
 
Method Summary
 void close()
          Close the underlying InputStream
 byte[] read()
          Read the next record and return as a new byte array
 int read(byte[] bytes)
          Read the next record into the supplied byte array.
 int read(byte[] bytes, int offset)
          Read the next record into the supplied byte array starting at offset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RDWInputRecordStream

public RDWInputRecordStream(java.io.InputStream is)
Construct an instance of RDWInputRecordStream. Supplying a BufferedInputStream wrapper will generally result in better performance.

Parameters:
is - the InputStream containing RDW delineated records
Method Detail

close

public void close()
           throws java.io.IOException
Close the underlying InputStream

Throws:
java.io.IOException

read

public int read(byte[] bytes)
         throws java.io.IOException
Read the next record into the supplied byte array.

Parameters:
bytes - the byte[] to read the record into
Returns:
int the length of the record or -1 if EOF
Throws:
java.io.IOException - if the supplied byte[] is too small to hold the record or if an exception occurs on the underlying InputStream

read

public int read(byte[] bytes,
                int offset)
         throws java.io.IOException
Read the next record into the supplied byte array starting at offset.

Parameters:
bytes - the byte[] to read the record into
Returns:
int the length of the record or -1 if EOF
Throws:
java.io.IOException - if the supplied byte[] is too small to hold the record or if an exception occurs on the underlying InputStream

read

public byte[] read()
            throws java.io.IOException
Read the next record and return as a new byte array

This method creates a new byte array for each record sized to match the exact record length. For better performance, use read(byte[]).

Returns:
byte[] the record or null if EOF
Throws:
java.io.IOException - if the supplied byte[] is too small to hold the record or if an exception occurs on the underlying InputStream