Package org.basex.io.out
Class PrintOutput
java.lang.Object
java.io.OutputStream
org.basex.io.out.PrintOutput
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
- Direct Known Subclasses:
ArrayOutput,EncoderOutput,NewlineOutput,NullOutput
This class is a stream-wrapper for textual data encoded in UTF8.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longMaximum numbers of bytes to write.protected final OutputStreamOutput stream reference (can benull).protected longNumber of bytes written. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()booleanfinished()Checks if the output stream is exhausted.final voidflush()static PrintOutputget(OutputStream out) Returns a new instance for the given output stream.voidprint(byte[] token) Prints a token to the output stream.voidprint(int cp) Prints a single codepoint.voidPrints a string to the output stream.final voidprintln(byte[] token) Prints a token to the output stream, followed by a system-specific newline.final voidPrints a string and newline to the output stream.final voidsetLimit(int limit) Sets the maximum number of bytes to be written.final longsize()Returns the number of written bytes.voidwrite(int b) Methods inherited from class java.io.OutputStream
nullOutputStream, write, write
-
Field Details
-
os
Output stream reference (can benull). -
max
protected long maxMaximum numbers of bytes to write. -
size
protected long sizeNumber of bytes written.
-
-
Constructor Details
-
PrintOutput
Constructor, given a filename.- Parameters:
file- file- Throws:
IOException- I/O exception
-
-
Method Details
-
get
Returns a new instance for the given output stream.- Parameters:
out- output stream reference- Returns:
- print output
-
setLimit
public final void setLimit(int limit) Sets the maximum number of bytes to be written. Note that the limit might break unicode characters.- Parameters:
limit- maximum
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
print
Prints a single codepoint.- Parameters:
cp- codepoint to be printed- Throws:
IOException- I/O exception
-
print
Prints a token to the output stream.- Parameters:
token- token to be written- Throws:
IOException- I/O exception
-
print
Prints a string to the output stream.- Parameters:
string- string to be written- Throws:
IOException- I/O exception
-
println
Prints a string and newline to the output stream.- Parameters:
string- string to be written- Throws:
IOException- I/O exception
-
println
Prints a token to the output stream, followed by a system-specific newline.- Parameters:
token- token to be written- Throws:
IOException- I/O exception
-
size
public final long size()Returns the number of written bytes.- Returns:
- number of written bytes
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
finished
public boolean finished()Checks if the output stream is exhausted.- Returns:
trueif stream is exhausted
-