public class OutputStreamPrinter extends Printer implements BinaryOutput
An extension of Printer that encodes the text with a provided encoder and sends the resulting bytes on an
OutputStream. The instance can be configured to have different behavior on failure of the output stream.
The ignoreOnFailure property will stop to make further invocations to the output stream if an exception is thrown by
the output stream except for the close() method.
IOException.
IOFailureFlow.IGNORE value ignores the exception.IOFailureFlow.RETHROW value rethrows the exception.IOFailureFlow.THROW_UNDECLARED value throws instead a UndeclaredIOException exception wrapping the
original exception.The class provides direct write access to the underlying output stream when the client of the stream can provides bytes directly.
| Constructor and Description |
|---|
OutputStreamPrinter(TextEncoder encoder,
OutputStream out)
Builds an instance with the failureFlow being
IOFailureFlow.RETHROW and a the ignoreOnFailure property set to
false. |
OutputStreamPrinter(TextEncoder encoder,
OutputStream out,
boolean flushOnClose)
Builds an instance with the failureFlow being
IOFailureFlow.RETHROW and a the ignoreOnFailure property set to
false. |
OutputStreamPrinter(TextEncoder encoder,
OutputStream out,
boolean flushOnClose,
int bufferSize)
Builds an instance with the failureFlow being
IOFailureFlow.RETHROW and a the ignoreOnFailure property set to
false. |
OutputStreamPrinter(TextEncoder encoder,
OutputStream out,
boolean flushOnClose,
int bufferSize,
boolean growing)
Builds an instance with the failureFlow being
IOFailureFlow.RETHROW and a the ignoreOnFailure property set to
false. |
OutputStreamPrinter(TextEncoder encoder,
OutputStream out,
IOFailureFlow failureFlow,
boolean ignoreOnFailure,
boolean flushOnClose,
int bufferSize)
Builds a new instance with the specified parameters and the delegate output.
|
OutputStreamPrinter(TextEncoder encoder,
OutputStream out,
IOFailureFlow failureFlow,
boolean ignoreOnFailure,
boolean flushOnClose,
int bufferSize,
boolean growing) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
void |
flushOutputStream()
Flush the output stream.
|
Charset |
getCharset() |
IOFailureFlow |
getFailureFlow()
Returns the failure flow.
|
boolean |
getIgnoreOnFailure()
Returns the ignore on failure property.
|
boolean |
isFailed() |
void |
write(byte b) |
void |
write(byte[] bytes) |
void |
write(byte[] bytes,
int off,
int len) |
void |
write(char[] cbuf) |
void |
write(char[] cbuf,
int off,
int len) |
void |
write(int c) |
void |
write(String str) |
void |
write(String str,
int off,
int len) |
public OutputStreamPrinter(TextEncoder encoder, OutputStream out, boolean flushOnClose) throws IllegalArgumentException
IOFailureFlow.RETHROW and a the ignoreOnFailure property set to
false.encoder - the encoderout - the outputflushOnClose - flush when stream is closedIllegalArgumentException - if any argument is nullpublic OutputStreamPrinter(TextEncoder encoder, OutputStream out, boolean flushOnClose, int bufferSize) throws IllegalArgumentException
IOFailureFlow.RETHROW and a the ignoreOnFailure property set to
false.encoder - the encoderout - the outputflushOnClose - flush when stream is closedbufferSize - the size of the bufferIllegalArgumentException - if any argument is nullpublic OutputStreamPrinter(TextEncoder encoder, OutputStream out, boolean flushOnClose, int bufferSize, boolean growing) throws IllegalArgumentException
IOFailureFlow.RETHROW and a the ignoreOnFailure property set to
false.encoder - the encoderout - the outputflushOnClose - flush when stream is closedbufferSize - the initial size of the buffergrowing - if the buffer should grow in size once fullIllegalArgumentException - if any argument is nullpublic OutputStreamPrinter(TextEncoder encoder, OutputStream out) throws IllegalArgumentException
IOFailureFlow.RETHROW and a the ignoreOnFailure property set to
false.encoder - the encoderout - the outputIllegalArgumentException - if any argument is nullpublic OutputStreamPrinter(TextEncoder encoder, OutputStream out, IOFailureFlow failureFlow, boolean ignoreOnFailure, boolean flushOnClose, int bufferSize) throws IllegalArgumentException
encoder - the encoderout - the outputfailureFlow - the control flow failureFlowignoreOnFailure - the behavior on failureflushOnClose - flush when stream is closedbufferSize - the buffer sizeIllegalArgumentException - if any argument is nullpublic OutputStreamPrinter(TextEncoder encoder, OutputStream out, IOFailureFlow failureFlow, boolean ignoreOnFailure, boolean flushOnClose, int bufferSize, boolean growing) throws IllegalArgumentException
IllegalArgumentExceptionpublic final Charset getCharset()
getCharset in interface BinaryOutputpublic final IOFailureFlow getFailureFlow()
public final boolean getIgnoreOnFailure()
public final boolean isFailed()
public final void write(byte b)
throws IOException
write in interface BinaryOutputIOExceptionpublic final void write(byte[] bytes)
throws IOException
write in interface BinaryOutputIOExceptionpublic final void write(byte[] bytes,
int off,
int len)
throws IOException
write in interface BinaryOutputIOExceptionpublic final void write(int c)
throws IOException
write in class WriterIOExceptionpublic final void write(char[] cbuf)
throws IOException
write in class WriterIOExceptionpublic final void write(String str) throws IOException
write in class WriterIOExceptionpublic final void write(String str, int off, int len) throws IOException
write in class WriterIOExceptionpublic final void write(char[] cbuf,
int off,
int len)
throws IOException
write in class WriterIOExceptionpublic final void flush()
throws IOException
flush in interface Flushableflush in class WriterIOExceptionpublic final void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class WriterIOExceptionpublic void flushOutputStream()
throws IOException
IOExceptionCopyright © 2017 JBoss by Red Hat. All Rights Reserved.