public class IndirectOutputStream extends OutputStream
IndirectOutputStream forwards all requests unmodified to
another output stream which may be changed at runtime. By default an
IOException will be thrown if no sink is configured when a
request is received. The stream may be configured to drop such requests
instead.| Constructor and Description |
|---|
IndirectOutputStream()
Creates a new
IndirectOutputStream with no sink which
fails when no sink is present. |
IndirectOutputStream(OutputStream sink)
Creates a new
IndirectOutputStream with the given sink
which fails when no sink is present. |
IndirectOutputStream(OutputStream sink,
boolean discard)
Creates a new
IndirectOutputStream with the given sink
and behavior when no sink is present. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
discardOnNoSink()
Gets the current behavior when no wink is present.
|
void |
discardOnNoSink(boolean discard)
Sets the behavior when no sink is present.
|
void |
flush() |
OutputStream |
getSink()
Gets the currently configured sink.
|
void |
setSink(OutputStream sink)
Sets the stream to which requests are forwarded.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public IndirectOutputStream()
IndirectOutputStream with no sink which
fails when no sink is present.public IndirectOutputStream(OutputStream sink)
IndirectOutputStream with the given sink
which fails when no sink is present.sink - the initial sinkpublic IndirectOutputStream(OutputStream sink, boolean discard)
IndirectOutputStream with the given sink
and behavior when no sink is present.sink - the initial sinkdiscard - whether to discard requests when no sink is presentpublic OutputStream getSink()
null if no sink presentpublic void setSink(OutputStream sink)
sink - the stream to which requests should be forwarded
or null to remove the current sinkpublic boolean discardOnNoSink()
public void discardOnNoSink(boolean discard)
discard - whether to discard requests when no sink is presentpublic void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in class OutputStreamIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionCopyright © 2002–2019 Starter Inc.. All rights reserved.