public final class OutputStreams extends Object
OutputStream
s.Modifier and Type | Field and Description |
---|---|
static OutputStream |
DISCARD
An
OutputStream that discards all bytes written to it. |
Modifier and Type | Method and Description |
---|---|
static OutputStream |
byteConsumerOutputStream(ConsumerWhichThrows<? super Byte,? extends IOException> delegate) |
static OutputStream[] |
compareOutput(int n,
Runnable whenIdentical,
Runnable whenNotIdentical)
Creates and returns an array of n
OutputStream s. |
static void |
fill(OutputStream outputStream,
byte b,
long count)
Writes count bytes of value b to the given outputStream.
|
static OutputStream |
lengthWritten(Consumer<? super Integer> delegate)
Creates and returns an
OutputStream which ignores the data written to it and only honors the
number of bytes written:
Every time data is written to the OutputStream , it invokes the consume() method on the delegate with the number of bytes written (not the cumulated number
of bytes written!). |
static OutputStream |
split(ProducerWhichThrows<? extends OutputStream,? extends IOException> delegates,
Producer<? extends Long> byteCountLimits)
Creates and returns an
OutputStream which writes at most byteCountLimits.produce()
bytes to delegates.produce() before closing it and writing the next
byteCountLimits.produce() bytes to delegates.produce() , and so on. |
static OutputStream |
tee(OutputStream... delegates)
Creates and returns an
OutputStream that delegates all work to the given delegates:
The write() methods write the given data to all the delegates;
if any of these throw an IOException , it is rethrown, and it is undefined whether all the data was
written to all the delegates. |
static OutputStream |
unclosable(OutputStream delegate) |
static OutputStream |
unclosableOutputStream(OutputStream delegate)
Deprecated.
Use
unclosable(OutputStream) instead |
static long |
writeAndCount(ConsumerWhichThrows<? super OutputStream,? extends IOException> writeContents,
OutputStream outputStream)
Invokes writeContents
.consume() with an output stream subject that writes the data through to
the given outputStream. |
public static final OutputStream DISCARD
OutputStream
that discards all bytes written to it.public static OutputStream tee(OutputStream... delegates)
OutputStream
that delegates all work to the given delegates:
write()
methods write the given data to all the delegates;
if any of these throw an IOException
, it is rethrown, and it is undefined whether all the data was
written to all the delegates.
flush()
flushes the delegates; throws the first IOException
that any
of the delegates throws.
close()
attempts to close all the delegates; if any of these
throw IOException
s, one of them is rethrown.
public static long writeAndCount(ConsumerWhichThrows<? super OutputStream,? extends IOException> writeContents, OutputStream outputStream) throws IOException
.consume()
with an output stream subject that writes the data through to
the given outputStream.IOException
public static OutputStream split(ProducerWhichThrows<? extends OutputStream,? extends IOException> delegates, Producer<? extends Long> byteCountLimits) throws IOException
OutputStream
which writes at most byteCountLimits.produce()
bytes to delegates.produce()
before closing it and writing the next
byteCountLimits.produce()
bytes to delegates.produce()
, and so on.delegates
- Must produce a (non-null
) series of OutputStream
sbyteCountLimits
- Must produce a (non-null
) series of Long
sIOException
@Deprecated public static OutputStream unclosableOutputStream(OutputStream delegate)
unclosable(OutputStream)
insteadOutputStream
which ignores all invocations of OutputStream.close()
public static OutputStream unclosable(OutputStream delegate)
OutputStream
which ignores all invocations of OutputStream.close()
public static void fill(OutputStream outputStream, byte b, long count) throws IOException
IOException
public static OutputStream byteConsumerOutputStream(ConsumerWhichThrows<? super Byte,? extends IOException> delegate)
public static OutputStream[] compareOutput(int n, Runnable whenIdentical, Runnable whenNotIdentical)
OutputStream
s.
Iff exactly the same bytes are written to all of these streams, and then all the streams are closed, then whenIdentical will be run (exactly once).
Otherwise, when the first non-identical byte is written to one of the streams, or at the latest when that stream is closed, whenNotIdentical will be run (possibly more than once).
public static OutputStream lengthWritten(Consumer<? super Integer> delegate)
OutputStream
which ignores the data written to it and only honors the
number of bytes written:
Every time data is written to the OutputStream
, it invokes the consume()
method on the delegate with the number of bytes written (not the cumulated number
of bytes written!).
Copyright © 2018 Arno Unkrig. All rights reserved.