net.sf.hermesftp.streams
Class TextOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by net.sf.hermesftp.streams.TextOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, RecordWriteSupport

public class TextOutputStream
extends java.io.OutputStream
implements RecordWriteSupport

Returns text data as byte arrays. In contrast to WriterOutputStream this class supports records. Internally, the a Writer is used to perform the translation from characters to bytes.

Author:
Lars Behnke

Constructor Summary
TextOutputStream(java.io.OutputStream os, java.lang.String outputEncoding)
          Constructor.
TextOutputStream(java.io.OutputStream os, java.lang.String outputEncoding, java.lang.String inputEncoding)
          Constructor.
 
Method Summary
 void close()
          
 void flush()
          Flushes any buffered record data.
 void write(int b)
          
 void writeRecord(byte[] data, boolean eof)
          Writes out a whole record.
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextOutputStream

public TextOutputStream(java.io.OutputStream os,
                        java.lang.String outputEncoding)
                 throws java.io.UnsupportedEncodingException
Constructor.

Parameters:
os - The output stream.
outputEncoding - The encoding of outbound text data.
Throws:
java.io.UnsupportedEncodingException - Thrown if encoding is unknown.

TextOutputStream

public TextOutputStream(java.io.OutputStream os,
                        java.lang.String outputEncoding,
                        java.lang.String inputEncoding)
                 throws java.io.UnsupportedEncodingException
Constructor.

Parameters:
os - The output stream.
outputEncoding - The encoding of outbound text data.
inputEncoding - The encoding of inbound text data.
Throws:
java.io.UnsupportedEncodingException - Thrown if encoding is unknown.
Method Detail

write

public void write(int b)
           throws java.io.IOException

Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

writeRecord

public void writeRecord(byte[] data,
                        boolean eof)
                 throws java.io.IOException
Writes out a whole record.

Specified by:
writeRecord in interface RecordWriteSupport
Parameters:
data - The record data.
eof - True, if last record is passed.
Throws:
java.io.IOException - Thrown if writing fails.

flush

public void flush()
           throws java.io.IOException
Flushes any buffered record data.

Specified by:
flush in interface java.io.Flushable
Specified by:
flush in interface RecordWriteSupport
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - Thrown if IO fails.

close

public void close()
           throws java.io.IOException

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


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