PrintStream

open class PrintStream(autoFlush: Boolean = false, out: OutputStream) : FilterOutputStream

caution: only minimum functionality which is called by lucene is implemented

A {@code PrintStream} adds functionality to another output stream, namely the ability to print representations of various data values conveniently. Two other features are provided as well. Unlike other output streams, a {@code PrintStream} never throws an {@code IOException}; instead, exceptional situations merely set an internal flag that can be tested via the {@code checkError} method. Optionally, a {@code PrintStream} can be created so as to flush automatically; this means that the {@code flush} method of the underlying output stream is automatically invoked after a byte array is written, one of the {@code println} methods is invoked, or a newline character or byte ({@code '\n'}) is written.

All characters printed by a {@code PrintStream} are converted into bytes using the given encoding or charset, or the default charset if not specified. The {@link PrintWriter} class should be used in situations that require writing characters rather than bytes.

This class always replaces malformed and unmappable character sequences with the charset's default replacement string. The {@linkplain java.nio.charset.CharsetEncoder} class should be used when more control over the encoding process is required.

Author

Frank Yellin

Mark Reinhold

Since

1.0

See also

#defaultCharset()

Constructors

Link copied to clipboard
constructor(autoFlush: Boolean = false, out: OutputStream)
constructor(out: OutputStream, autoFlush: Boolean, charset: Charset)

Creates a new print stream, with the specified OutputStream, line flushing and charset. This convenience constructor creates the necessary intermediate java.io.OutputStreamWriter, which will encode characters using the provided charset.

Functions

Link copied to clipboard
open override fun close()

Closes the stream. This is done by flushing the stream and then closing the underlying output stream.

Link copied to clipboard
open override fun flush()

Flushes the stream. This is done by writing any buffered output bytes to the underlying output stream and then flushing that stream.

Link copied to clipboard

Returns true if the stream is closed. This method is added to allow subclasses to check the closed state.

Link copied to clipboard
open fun print(x: String?)
Link copied to clipboard
open fun println()

Terminates the current line by writing the line separator string. The line separator string is defined by the system property {@code line.separator}, and is not necessarily a single newline character ({@code '\n'}).

open fun println(x: String?)

Prints a String and then terminates the line. This method behaves as though it invokes .print and then .println.

Link copied to clipboard
open override fun write(b: ByteArray)

Writes b.length bytes to this output stream.

open override fun write(b: Int)

Writes the specified byte to this output stream.

open override fun write(b: ByteArray, off: Int, len: Int)

Writes len bytes from the specified byte array starting at offset off to this output stream.