Sharkysoft home

lava.io
Class AsciiOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.FilterOutputStream
              |
              +--lava.io.AsciiOutputStream

public class AsciiOutputStream
extends java.io.FilterOutputStream

ASCII output stream.

Details: AsciiOutputStream is an OutputStream with extensions for writing Strings in 8-bit ASCII regardless of the platform's character encoding. In the write and writeln methods, which write Strings, each character in the string is cast directly into a single byte, using only the low order 8 bits, before it is written.

This class is especially useful in internationalizable code that, for some functions, must speak ASCII in order to work properly.

Since:
2000.01.20
Author:
Sharky

Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
AsciiOutputStream(java.io.OutputStream out)
          Sets forwarding OutputStream.
 
Method Summary
 java.lang.String getLineSeparator()
          Returns current line separator.
 void setLineSeparator(java.lang.String ls)
          Sets line separator.
 void write(java.lang.String text)
          Writes ASCII string.
 void writeln()
          Terminates line.
 void writeln(java.lang.String line)
          Writes ASCII line.
 
Methods inherited from class java.io.FilterOutputStream
close, flush, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsciiOutputStream

public AsciiOutputStream(java.io.OutputStream out)
Sets forwarding OutputStream.

Details: This constructor binds this AsciiOutputStream to the given OutputStream (out). All output produced by this AsciiOutputStream will be forwarded to out.

Parameters:
out - the target output stream
Method Detail

setLineSeparator

public void setLineSeparator(java.lang.String ls)
Sets line separator.

Details: setLineSeparator sets the current line separator which writeln will use. If ls is null, the platform's default line separator will be used.

Parameters:
ls - the new line separator

getLineSeparator

public java.lang.String getLineSeparator()
Returns current line separator.

Details: getLineSeparator returns the line separator currently being used by the writeln method. Note that this value will never be null, even null was passed to setLineSeparator.

The writelns call this method once for each call, and use the result to terminate the line it is writing. Thus, some interesting line termination effects may be achieved by subclassing and overriding this method.

Returns:
the current line separator

write

public void write(java.lang.String text)
           throws java.io.IOException
Writes ASCII string.

Details: write converts the given string (text) into an array of bytes and sends them to the target OutputStream.

This method is called by writeln, so be careful when overriding it.

Parameters:
text - the string to write
Throws:
java.io.IOException - if an I/O error occurs

writeln

public void writeln(java.lang.String line)
             throws java.io.IOException
Writes ASCII line.

Details: writeln adds a line terminator to the given string (line) and forwards it to write(String).

Parameters:
line - the line to write
Throws:
java.io.IOException - if an I/O error occurs

writeln

public void writeln()
             throws java.io.IOException
Terminates line.

Details: writeln forwards the current defined line terminator to write(String).

Throws:
java.io.IOException - if an I/O error occurs

Sharkysoft home