public class StreamCopier extends java.lang.Object implements IOCopier
InputStream to a
OutputStream.
Typical usage:
input = new FileInputStream(FileLib.createFile("data/copyfrom.dat");
output = new FileOutputStream(FileLib.createFile("data/copyto.dat");
copier = new StreamCopier(input, output);
copier.copy();
copier.close();
Copyright 2006 Partner Software, Inc.
| Constructor and Description |
|---|
StreamCopier(java.io.InputStream source,
java.io.OutputStream sink)
Constructs a StreamCopier for the given source and sink with standard
buffer size.
|
StreamCopier(java.io.InputStream source,
java.io.OutputStream sink,
byte[] buffer)
Constructs a StreamCopier for the given source, sink, and buffer.
|
StreamCopier(java.io.InputStream source,
java.io.OutputStream sink,
int bufferSize)
Constructs a StreamCopier for the given source, sink, and buffer size.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes input source and output sink.
|
long |
copy()
Copies all available data from the source to the sink.
|
long |
copy(long howMuch)
Copies the specified amount of data from the source to the sink.
|
long |
copyBlockingOnce()
Block only once, copying available data, but quit as soon as a block would occur.
|
long |
copyWithoutBlocking()
Copies only available data.
|
long |
getCopiedByteCount() |
public StreamCopier(java.io.InputStream source,
java.io.OutputStream sink,
byte[] buffer)
public StreamCopier(java.io.InputStream source,
java.io.OutputStream sink,
int bufferSize)
public StreamCopier(java.io.InputStream source,
java.io.OutputStream sink)
IOConstants.BUFFER_SIZEpublic long copy()
throws java.io.IOException
IOCopierpublic long copy(long howMuch)
throws java.io.IOException
IOCopierpublic long copyWithoutBlocking()
throws java.io.IOException
IOCopierThis method is optional, if it's not appropriate for the kind of copy, throws an UnsupportedOperationException.
copyWithoutBlocking in interface IOCopierjava.io.IOExceptionpublic long copyBlockingOnce()
throws java.io.IOException
IOCopierThis method is optional, if it's not appropriate for the kind of copy, throws an UnsupportedOperationException.
copyBlockingOnce in interface IOCopierjava.io.IOExceptionpublic void close()
throws java.io.IOException
IOCopierpublic long getCopiedByteCount()