net.sf.hermesftp.streams
Class TextInputStream

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

public class TextInputStream
extends java.io.InputStream
implements RecordReadSupport

Reads text data and makes the lines accessible as records. The records are returned as byte arrays. Internally, the a Reader is used to perform the translation from characters to bytes.

Author:
Lars Behnke

Constructor Summary
TextInputStream(java.io.InputStream is, java.lang.String inputEncoding)
          Constructor.
TextInputStream(java.io.InputStream is, java.lang.String inputEncoding, java.lang.String outputEncoding)
          Constructor.
 
Method Summary
 void close()
          
 int read()
          
 byte[] readRecord()
          Reads a whole record without delimiters.
 
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

TextInputStream

public TextInputStream(java.io.InputStream is,
                       java.lang.String inputEncoding)
                throws java.io.UnsupportedEncodingException
Constructor.

Parameters:
is - The input stream.
inputEncoding - The encoding.
Throws:
java.io.UnsupportedEncodingException - Thrown if encoding is unknown.

TextInputStream

public TextInputStream(java.io.InputStream is,
                       java.lang.String inputEncoding,
                       java.lang.String outputEncoding)
                throws java.io.UnsupportedEncodingException
Constructor.

Parameters:
is - The input stream.
inputEncoding - The encoding of the inbound text data.
outputEncoding - The encoding of the outbound text data.
Throws:
java.io.UnsupportedEncodingException - Thrown if encoding is unknown.
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 whole record without delimiters.

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

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.