public class StreamCopier extends Object
InputStream
s to
OutputStream
s. Can be used in conjunction with an
active thread - see getInterruptibleRunnable(java.io.InputStream, java.io.OutputStream)
.Constructor and Description |
---|
StreamCopier(int bufferSize,
boolean closeStreams)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
copy(InputStream in,
OutputStream out)
Copies from the input stream to the output stream until the input
stream is empty or one of the streams reports an error.
|
InterruptibleRunnable |
getInterruptibleRunnable(InputStream in,
OutputStream out)
Creates a
InterruptibleRunnable that can be used to copy a
stream with an active Thread. |
Runnable |
getRunnable(InputStream in,
OutputStream out)
Convenience version of
getInterruptibleRunnable(InputStream, OutputStream) that returns a
Runnable . |
public StreamCopier(int bufferSize, boolean closeStreams)
bufferSize
- The buffer size.closeStreams
- true
=> ensure the streams are
closed after copying.public void copy(InputStream in, OutputStream out) throws IOException
Not thread safe - use multiple StreamCopier
instances instead.
in
- Input stream.out
- Output stream.IOException
- If an IO problem occurred during the copy.public InterruptibleRunnable getInterruptibleRunnable(InputStream in, OutputStream out)
InterruptibleRunnable
that can be used to copy a
stream with an active Thread.
Any exceptions that occur during processing are simply discarded.
in
- Input stream.out
- Output stream.InterruptibleRunnable
.public Runnable getRunnable(InputStream in, OutputStream out)
getInterruptibleRunnable(InputStream, OutputStream)
that returns a
Runnable
.in
- Input stream.out
- Output stream.InterruptibleRunnable
.Copyright © 2000-2014. All Rights Reserved.