@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) @ThreadSafe public final class Streams extends Object
InputStreams and
OutputStreams.| Modifier and Type | Class and Description |
|---|---|
private static class |
Streams.Buffer
A buffer for I/O.
|
private static class |
Streams.InputStreamReaderThreadFactory
A factory for input stream reader threads.
|
| Modifier and Type | Field and Description |
|---|---|
private static ExecutorService |
executor |
| Modifier | Constructor and Description |
|---|---|
private |
Streams()
You cannot instantiate this class.
|
| Modifier and Type | Method and Description |
|---|---|
private static Streams.Buffer[] |
allocateBuffers() |
static void |
cat(InputStream in,
OutputStream out)
Copies the data from the given input stream to the given output stream
without closing them.
|
static void |
copy(InputStream in,
OutputStream out)
Copies the data from the given input stream to the given output stream
and always closes both streams - even if an exception
occurs.
|
private static void |
releaseBuffers(Streams.Buffer[] buffers) |
private static final ExecutorService executor
public static void copy(InputStream in, OutputStream out) throws IOException
This is a high performance implementation which uses a pooled background thread to fill a FIFO of pooled buffers which is concurrently flushed by the current thread. It performs best when used with unbuffered streams.
in - the input stream.out - the output stream.InputException - if copying the data fails because of an
IOException in the input stream.IOException - if copying the data fails because of an
IOException in the output stream.public static void cat(InputStream in, OutputStream out) throws IOException
OutputStream.flush() unless an
IOException occurs when writing to the output stream.
This hold true even if an IOException occurs when reading from
the input stream.
This is a high performance implementation which uses a pooled background thread to fill a FIFO of pooled buffers which is concurrently flushed by the current thread. It performs best when used with unbuffered streams.
The name of this method is inspired by the Unix command line utility
cat because you could use it to concatenate the contents
of multiple streams.
in - the input stream.out - the output stream.InputException - if copying the data fails because of an
IOException in the input stream.IOException - if copying the data fails because of an
IOException in the output stream.private static Streams.Buffer[] allocateBuffers()
private static void releaseBuffers(Streams.Buffer[] buffers)
Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.