public class StreamCopier
extends java.lang.Object
implements java.lang.Runnable
Constructor and Description |
---|
StreamCopier(java.io.InputStream inStream,
boolean closeIn,
java.io.OutputStream outStream,
boolean closeOut)
Creates a StreamCopier that reads from inStream and writes to outStream.
|
StreamCopier(java.io.InputStream inStream,
java.io.OutputStream outStream)
Creates a StreamCopier that reads from inStream and writes to outStream.
|
Modifier and Type | Method and Description |
---|---|
void |
copyStream()
Start the copying.
|
java.io.IOException |
getException()
Get the IOException that occured during copying (if any).
|
boolean |
isActive()
Check whether the copier is already finished.
|
void |
run()
Run method to allow the StreamCopier to be run in a separate Thread easily.
|
void |
setCloseIn(boolean closeIn)
Set whether the InputStream shall be closed after copying.
|
void |
setCloseOut(boolean closeOut)
Set whether the OutputStream shall be closed after copying.
|
void |
waitFinished()
Wait for the StreamCopier to finish.
|
public StreamCopier(java.io.InputStream inStream, java.io.OutputStream outStream)
public StreamCopier(java.io.InputStream inStream, boolean closeIn, java.io.OutputStream outStream, boolean closeOut)
public void setCloseIn(boolean closeIn)
public void setCloseOut(boolean closeOut)
public boolean isActive()
public void copyStream() throws java.io.IOException
read()
returns -1) or until an Exception occurs. If an
IOException occurs, this method will still continue and close the stream,
etc., but the Exception will be remembered and thrown at the end of the
method (only EOFExceptions are not thrown, as they may occur in normal
operations). If a Thread is waiting for the copy to finish (see
waitFinished()
) it will be awaken when copying is done.java.io.IOException
public void waitFinished()
public void run()
copyStream()
and ignores Exceptions.run
in interface java.lang.Runnable
public java.io.IOException getException()