org.basex.io
Class PrintOutput

java.lang.Object
  extended by java.io.OutputStream
      extended by org.basex.io.PrintOutput
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Direct Known Subclasses:
CachedOutput, ConsoleOutput, 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:
Workgroup DBIS, University of Konstanz 2005-08, ISC License, Christian Gruen

Constructor Summary
PrintOutput(java.io.OutputStream out)
          Constructor, given an output stream.
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()
           
 void print(byte[] token)
          Writes a token to the output stream.
 void print(byte[] str, int i)
          Writes a string to the output stream.
 void print(char ch)
          Writes a character to the output stream.
 void print(int i, byte[] str)
          Writes a string to the output stream.
 void print(java.lang.String str)
          Writes a string to the output stream.
 void println()
          Writes a newline to the output stream.
 void println(byte[] token)
          Writes a token to the output stream.
 void println(java.lang.String str)
          Writes a string and newline to the output stream.
 int size()
          Returns the number of written bytes.
 void write(int b)
           
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
equals, 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 - in case of write errors

PrintOutput

public PrintOutput(java.io.OutputStream out)
Constructor, given an output stream.

Parameters:
out - the OutputStream to operate on
Method Detail

write

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

print

public final void print(char ch)
                 throws java.io.IOException
Writes a character to the output stream.

Parameters:
ch - string to be written
Throws:
java.io.IOException - in case of write errors

print

public final void print(int i,
                        byte[] str)
                 throws java.io.IOException
Writes a string to the output stream.

Parameters:
str - string to be written
i - number of spaces to indent
Throws:
java.io.IOException - in case of write errors

print

public final void print(byte[] str,
                        int i)
                 throws java.io.IOException
Writes a string to the output stream.

Parameters:
str - string to be written
i - number of spaces to indent
Throws:
java.io.IOException - in case of write errors

print

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

Parameters:
str - string to be written
Throws:
java.io.IOException - in case of write errors

println

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

Parameters:
str - string to be written
Throws:
java.io.IOException - in case of write errors

println

public final void println()
                   throws java.io.IOException
Writes a newline to the output stream.

Throws:
java.io.IOException - in case of write errors

print

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

Parameters:
token - token to be written
Throws:
java.io.IOException - in case of write errors

println

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

Parameters:
token - token to be written
Throws:
java.io.IOException - in case of write errors

size

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

Returns:
number of written bytes.

flush

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