Package org.basex.io.out
Class ArrayOutput
java.lang.Object
java.io.OutputStream
org.basex.io.out.PrintOutput
org.basex.io.out.ArrayOutput
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
This class caches the output bytes in an array, similar to
ByteArrayOutputStream.
This implementation is faster because functions are not synchronized.- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
Fields inherited from class org.basex.io.out.PrintOutput
max, os, size -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]buffer()Returns the internal buffer.byte[]finish()Returns the output as byte array, and invalidates the internal array.byte[]next()Returns an array with all elements and resets the internal buffer.voidreset()Resets the internal buffer.byte[]toArray()Returns the output as byte array.toString()voidwrite(int b) Methods inherited from class org.basex.io.out.PrintOutput
close, finished, flush, get, print, print, print, println, println, setLimit, sizeMethods inherited from class java.io.OutputStream
nullOutputStream, write, write
-
Constructor Details
-
ArrayOutput
public ArrayOutput()Constructor.
-
-
Method Details
-
write
public void write(int b) - Overrides:
writein classPrintOutput
-
toArray
public byte[] toArray()Returns the output as byte array.- Returns:
- byte array
-
next
public byte[] next()Returns an array with all elements and resets the internal buffer.- Returns:
- array
-
finish
public byte[] finish()Returns the output as byte array, and invalidates the internal array. Warning: the function must only be called if the output stream is discarded afterwards.- Returns:
- token
-
buffer
public byte[] buffer()Returns the internal buffer.- Returns:
- buffer
-
reset
public void reset()Resets the internal buffer. -
toString
-