tribble.io
Class WriterOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by tribble.io.WriterOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class WriterOutputStream
extends java.io.OutputStream

Pass-through character writer stream.

Writes characters to an underlying Writer object, writing individual output bytes as 8-bit character codes. This is effectively a character stream that writes ISO 8859-1 character codes as uninterpreted single-byte sequences, i.e., each character code is composed of a single 8-bit octet written to the output stream.

This class is essentially the inverse of class OutputStreamWriter.

Since:
2005-04-08
Version:
$Revision: 1.1 $ $Date: 2005/04/09 04:18:20 $
Author:
David R. Tribble (david@tribble.com).
Copyright ©2005 by David R. Tribble, all rights reserved.
Permission is granted to freely use and distribute this source code provided that the original copyright and authorship notices remain intact.
See Also:
ReaderInputStream, PassThruWriter, OutputStreamWriter

Field Summary
protected  java.io.Writer m_out
          Underlying output stream writer.
protected static java.lang.String NEWLINE
          Platform-specific newline character sequence.
(package private) static java.lang.String REV
          Revision information.
 
Constructor Summary
WriterOutputStream(java.io.Writer out)
          Constructor.
 
Method Summary
 void close()
          Flush and close this output stream.
 void flush()
          Flush any pending output to this output stream.
 void newLine()
          Write a newline sequence to this output stream.
 void write(byte[] buf)
          Write a group of characters.
 void write(byte[] buf, int off, int len)
          Write a group of characters.
 void write(int ch)
          Write a single character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REV

static final java.lang.String REV
Revision information.

See Also:
Constant Field Values

NEWLINE

protected static final java.lang.String NEWLINE
Platform-specific newline character sequence.


m_out

protected java.io.Writer m_out
Underlying output stream writer.

Constructor Detail

WriterOutputStream

public WriterOutputStream(java.io.Writer out)
Constructor.

Parameters:
out - Underlying output stream, which provides a destination for output bytes.
Since:
1.1, 2005-04-08
Method Detail

close

public void close()
           throws java.io.IOException
Flush and close this output stream.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException - Thrown if an I/O error occurs while closing the underlying output writer.
Since:
1.1, 2005-04-08

flush

public void flush()
           throws java.io.IOException
Flush any pending output to this output stream.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - Thrown if an I/O error occurs while closing the underlying output writer.
Since:
1.1, 2005-04-08

write

public void write(int ch)
           throws java.io.IOException
Write a single character.

Specified by:
write in class java.io.OutputStream
Parameters:
ch - A character byte. Only the lower 8 bits of the character are used (yielding characters in the range [0x0000,0x00FF]).
Throws:
java.io.IOException - Thrown if an I/O error occurs while writing to the underlying output writer.
Since:
1.1, 2005-04-08

write

public void write(byte[] buf)
           throws java.io.IOException
Write a group of characters.

This method has exactly the same effect as the call: write(buf, 0, buf.length).

Overrides:
write in class java.io.OutputStream
Parameters:
buf - (const) An array of character bytes to be written. Each byte represents a single 8-bit character code in the range [0x0000,0x00FF].
Throws:
java.io.IOException - Thrown if an I/O error occurs while writing to the underlying output writer.
Since:
1.1, 2005-04-08

write

public void write(byte[] buf,
                  int off,
                  int len)
           throws java.io.IOException
Write a group of characters.

Overrides:
write in class java.io.OutputStream
Parameters:
buf - (const) An array of character bytes to be written. Each byte represents a single 8-bit character code in the range [0x0000,0x00FF].
off - Index of the first character in buf to write.
len - Number of characters in buf to write.
Throws:
java.io.IOException - Thrown if an I/O error occurs while writing to the underlying output writer.
Since:
1.1, 2005-04-08

newLine

public void newLine()
             throws java.io.IOException
Write a newline sequence to this output stream.

If the underlying stream is a PrintWriter, its println() method is called;
if the stream is a BufferedWriter, its newLine() method is called;
otherwise, the native newline character sequence is written to it by calling its write() method.

Throws:
java.io.IOException - Thrown if an I/O error occurs while writing to the underlying output writer.
Since:
1.1, 2005-04-08