org.basex.io.out
Class ArrayOutput

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

public final class ArrayOutput
extends PrintOutput

This class caches the output bytes in an array, similar to the ByteArrayOutputStream class. Bytes that exceed an optional maximum are ignored.

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

Constructor Summary
ArrayOutput()
           
 
Method Summary
 byte[] buffer()
          Returns the internal buffer.
 boolean finished()
          Checks if stream can output more characters; can be overwritten to interrupt streaming at some point.
 ArrayOutput max(int m)
          Sets the maximum number of bytes to be written.
 void reset()
          Resets the internal buffer.
 byte[] toArray()
          Returns the output as byte array.
 java.lang.String toString()
           
 void write(int b)
           
 
Methods inherited from class org.basex.io.out.PrintOutput
close, flush, get, print, print, println, println, size, utf8, writeString
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArrayOutput

public ArrayOutput()
Method Detail

max

public ArrayOutput max(int m)
Sets the maximum number of bytes to be written. Note that the limit might break unicode characters.

Parameters:
m - maximum
Returns:
self reference

write

public void write(int b)
Overrides:
write in class PrintOutput

toArray

public byte[] toArray()
Returns the output as byte array.

Returns:
byte array

finished

public boolean finished()
Description copied from class: PrintOutput
Checks if stream can output more characters; can be overwritten to interrupt streaming at some point.

Overrides:
finished in class PrintOutput
Returns:
result of check

buffer

public byte[] buffer()
Returns the internal buffer.

Returns:
buffer

reset

public void reset()
Resets the internal buffer.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object