org.basex.io.out
Class PrintOutput

java.lang.Object
  extended by java.io.OutputStream
      extended by org.basex.io.out.PrintOutput
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Direct Known Subclasses:
ArrayOutput, NullOutput

public class PrintOutput
extends java.io.OutputStream

This class is a stream-wrapper for textual data. Note that the internal byte representation (usually UTF8) will be directly output without further character conversion.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Constructor Summary
PrintOutput(java.lang.String fn)
          Constructor, given a filename.
 
Method Summary
 void close()
           
 boolean finished()
          Checks if stream can output more characters; can be overwritten to interrupt streaming at some point.
 void flush()
           
static PrintOutput get(java.io.OutputStream out)
          Returns a new instance for the given output stream.
 void print(byte[] token)
          Prints a token to the output stream.
 void print(java.lang.String str)
          Prints a string to the output stream.
 void println(byte[] token)
          Prints a token to the output stream.
 void println(java.lang.String str)
          Prints a string and newline to the output stream.
 long size()
          Returns the number of written bytes.
 void utf8(int ch)
          Writes a character as UTF8.
 void write(int b)
           
 void writeString(java.lang.String str)
          Writes a string to the output stream, suffixed by a 0 byte.
 
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

PrintOutput

public PrintOutput(java.lang.String fn)
            throws java.io.IOException
Constructor, given a filename.

Parameters:
fn - filename
Throws:
java.io.IOException - I/O exception
Method Detail

get

public static PrintOutput get(java.io.OutputStream out)
Returns a new instance for the given output stream.

Parameters:
out - output stream reference
Returns:
print output

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

utf8

public void utf8(int ch)
          throws java.io.IOException
Writes a character as UTF8.

Parameters:
ch - character to be printed
Throws:
java.io.IOException - I/O exception

writeString

public final void writeString(java.lang.String str)
                       throws java.io.IOException
Writes a string to the output stream, suffixed by a 0 byte.

Parameters:
str - string to be written
Throws:
java.io.IOException - I/O exception

print

public final void print(java.lang.String str)
                 throws java.io.IOException
Prints a string to the output stream.

Parameters:
str - string to be written
Throws:
java.io.IOException - I/O exception

println

public final void println(java.lang.String str)
                   throws java.io.IOException
Prints a string and newline to the output stream.

Parameters:
str - string to be written
Throws:
java.io.IOException - I/O exception

print

public final void print(byte[] token)
                 throws java.io.IOException
Prints a token to the output stream.

Parameters:
token - token to be written
Throws:
java.io.IOException - I/O exception

println

public final void println(byte[] token)
                   throws java.io.IOException
Prints a token to the output stream.

Parameters:
token - token to be written
Throws:
java.io.IOException - I/O exception

size

public final long size()
Returns the number of written bytes.

Returns:
number of written bytes

flush

public final void flush()
                 throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException

close

public final 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

finished

public boolean finished()
Checks if stream can output more characters; can be overwritten to interrupt streaming at some point.

Returns:
result of check