org.foray.common
Class CharacterOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by org.foray.common.CharacterOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class CharacterOutputStream
extends FilterOutputStream

Output stream used to write character-based data (that is, Strings) to a wrapped (byte-based) output stream. Has methods to write Strings as raw Strings and to write them as lines (appending an end-of-line character).


Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
CharacterOutputStream(OutputStream out, boolean commentsEnabled)
          Constructor.
 
Method Summary
 void comment(String comment)
          Writes a given comment, if comments are enabled.
 void write(CharSequence cmd)
          Writes text to the stream, adding a linefeed at the end.
 void writeByteArr(byte[] cmd)
          Writes an array of bytes to the output stream.
 void writeRaw(CharSequence cmd)
          Writes text to the stream (no linefeed is appended).
 
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

CharacterOutputStream

public CharacterOutputStream(OutputStream out,
                             boolean commentsEnabled)
Constructor.

Parameters:
out - The encapsulated OutputStream.
commentsEnabled - Indicates whether comments should be written. If false, the method comment(String) is ignored.
Method Detail

write

public void write(CharSequence cmd)
           throws IOException
Writes text to the stream, adding a linefeed at the end.

Parameters:
cmd - The text to be written to the output stream.
Throws:
IOException - For I/O errors during the write.

writeRaw

public void writeRaw(CharSequence cmd)
              throws IOException
Writes text to the stream (no linefeed is appended).

Parameters:
cmd - The text to be written to the output stream.
Throws:
IOException - For I/O errors during the write.

writeByteArr

public void writeByteArr(byte[] cmd)
                  throws IOException
Writes an array of bytes to the output stream.

Parameters:
cmd - The array of bytes to be written to the output stream.
Throws:
IOException - For I/O errors during the write.

comment

public void comment(String comment)
             throws IOException
Writes a given comment, if comments are enabled.

Parameters:
comment - The comment to be written.
Throws:
IOException - For I/O errors during the write.


Copyright © 2017. All rights reserved.