public final class ByteStreams extends Object
| Modifier and Type | Method and Description |
|---|---|
static InputStream |
concat(InputStream... streams)
Concatenates the given
InputStreams into a single one. |
static InputStream |
concat(Iterable<? extends InputStream> streams)
Concatenates the given
InputStreams into a single one. |
static void |
copy(InputStream in,
OutputStream out)
Copies the content of the given
InputStream into the given
OutputStream. |
static boolean |
equal(InputStream in1,
InputStream in2)
Returns whether the given streams have the same content.
|
static InputStream |
limit(InputStream in,
long limit)
Returns an
InputStream that will only supply bytes from the
given InputStream up to the specified limit. |
static byte[] |
read(InputStream in)
Reads the content of the given
InputStream. |
static OutputStream |
tee(Iterable<? extends OutputStream> streams)
Returns an
OutputStream that writes all bytes written to it
to the given underlying streams. |
static OutputStream |
tee(OutputStream... streams)
Returns an
OutputStream that writes all bytes written to it
to the given underlying streams. |
public static InputStream concat(InputStream... streams)
InputStreams into a single one. The
given streams will be read sequentially. Closing the concatenated
stream will close all the source streams. Note that the returned
InputStream is not thread-safe and does not support
InputStream.mark(int) and InputStream.reset().streams - the streams to concatenate.InputStream.NullPointerException - if streams is null or
if it contains a null reference.IllegalArgumentException - if streams is empty.public static InputStream concat(Iterable<? extends InputStream> streams)
InputStreams into a single one. The
given streams will be read sequentially. Closing the concatenated
stream will close all the source streams. Note that the returned
InputStream is not thread-safe and does not support
InputStream.mark(int) and InputStream.reset().streams - the streams to concatenate.InputStream.NullPointerException - if streams is null or
if it contains a null reference.IllegalArgumentException - if streams is empty.public static void copy(InputStream in, OutputStream out) throws IOException
InputStream into the given
OutputStream.in - the stream to read from.out - the stream to write on.NullPointerException - if one of the arguments is null.IOException - if an I/O error occurs during the process.public static boolean equal(InputStream in1, InputStream in2) throws IOException
in1 - the first stream.in2 - the second stream.true if the streams have the same content.IOException - if an I/O error occurs during the process.public static InputStream limit(InputStream in, long limit)
InputStream that will only supply bytes from the
given InputStream up to the specified limit. The returned
InputStream is thread-safe.in - the source stream.limit - the maximum number of bytes to be read from in.InputStream.NullPointerException - if in is null.IllegalArgumentException - if limit is negative.public static byte[] read(InputStream in) throws IOException
InputStream.in - the stream to read.NullPointerException - if in is null.IOException - if in can't be read.public static OutputStream tee(OutputStream... streams)
OutputStream that writes all bytes written to it
to the given underlying streams. Named after the Unix 'tee' command.
The returned instance is not thread-safe.streams - the streams to write to.OutputStream.NullPointerException - if streams is null or
if it contains a null reference.public static OutputStream tee(Iterable<? extends OutputStream> streams)
OutputStream that writes all bytes written to it
to the given underlying streams. Named after the Unix 'tee' command.
The returned instance is not thread-safe.streams - the streams to write to.OutputStream.NullPointerException - if streams is null or
if it contains a null reference.Copyright © 2012–2015. All rights reserved.