public class CopyStream
extends java.lang.Object
A class for copying an entire input stream to an output stream.
Modifier and Type | Method and Description |
---|---|
static void |
copy(java.io.File inFile,
java.io.File outFile)
Copy an entire input file to an output file.
|
static void |
copy(java.io.File inFile,
java.io.File outFile,
int readBufferSize,
int bufferedInputStreamSizeForFileCopy,
int bufferedOutputStreamSizeForFileCopy)
Copy an entire input file to an output file.
|
static void |
copy(java.io.InputStream in,
java.io.OutputStream out)
Copy an entire input stream to an output stream.
|
static void |
copy(java.io.InputStream in,
java.io.OutputStream out,
long count)
Copy the specified number of bytes from the current position of the input stream to an output stream.
|
static void |
copy(int readBufferSize,
java.io.InputStream in,
java.io.OutputStream out)
Copy an entire input stream to an output stream.
|
static void |
copy(int readBufferSize,
java.io.InputStream in,
java.io.OutputStream out,
long count)
Copy the specified number of bytes from the current position of the input stream to an output stream.
|
static void |
copy(java.lang.String inFile,
java.lang.String outFile)
Copy an entire input file to an output file.
|
static void |
copy(java.lang.String inFile,
java.lang.String outFile,
int readBufferSize,
int bufferedInputStreamSizeForFileCopy,
int bufferedOutputStreamSizeForFileCopy)
Copy an entire input file to an output file.
|
static void |
copyByteSwapped(java.io.InputStream in,
java.io.OutputStream out,
long count)
Copy the specified even number of bytes from the current position of the input stream to an output stream,
swapping adjacent pairs of bytes.
|
static void |
copyByteSwapped(int readBufferSize,
java.io.InputStream in,
java.io.OutputStream out,
long count)
Copy the specified even number of bytes from the current position of the input stream to an output stream,
swapping adjacent pairs of bytes.
|
static void |
main(java.lang.String[] arg)
Copy one file to another.
|
static void |
skipInsistently(java.io.InputStream in,
long length)
Skip as many bytes as requested, unless an exception occurs.
|
public static final void copy(java.io.File inFile, java.io.File outFile) throws java.io.IOException
Copy an entire input file to an output file.
inFile
- the sourceoutFile
- the destinationjava.io.IOException
- thrown if the copying fails for any reasonpublic static final void copy(java.io.File inFile, java.io.File outFile, int readBufferSize, int bufferedInputStreamSizeForFileCopy, int bufferedOutputStreamSizeForFileCopy) throws java.io.IOException
Copy an entire input file to an output file.
inFile
- the sourceoutFile
- the destinationreadBufferSize
- how much data to read in each requestbufferedInputStreamSizeForFileCopy
- the buffered input stream size (or zero if unbuffered)bufferedOutputStreamSizeForFileCopy
- and the buffered output stream size (or zero if unbuffered)java.io.IOException
- thrown if the copying fails for any reasonpublic static final void copy(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
Copy an entire input stream to an output stream.
The data is copied in chunks rather than as individual bytes, but the input and output
streams are used as is, and no BufferedInputStream
or BufferedOutputStream
is inserted; the caller
is expected to do that if maximum performance is desired.
Also, neither the input nor the output streams are explicitly closed after the copying has complete; the caller is expected to do that as well, since there may be occasions when there is more to be written to the output, or the input is to be rewound and reused, or whatever.
in
- the sourceout
- the destinationjava.io.IOException
- thrown if the copying fails for any reasonpublic static final void copy(java.io.InputStream in, java.io.OutputStream out, long count) throws java.io.IOException
Copy the specified number of bytes from the current position of the input stream to an output stream.
The data is copied in chunks rather than as individual bytes, but the input and output
streams are used as is, and no BufferedInputStream
or BufferedOutputStream
is inserted; the caller
is expected to do that if maximum performance is desired.
Also, neither the input nor the output streams are explicitly closed after the copying has complete; the caller is expected to do that as well, since there may be occasions when there is more to be written to the output, or the input is to be rewound and reused, or whatever.
in
- the sourceout
- the destinationcount
- the number of bytes to copyjava.io.IOException
- thrown if the copying fails for any reasonpublic static final void copy(int readBufferSize, java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
Copy an entire input stream to an output stream.
The data is copied in chunks rather than as individual bytes, but the input and output
streams are used as is, and no BufferedInputStream
or BufferedOutputStream
is inserted; the caller
is expected to do that if maximum performance is desired.
Also, neither the input nor the output streams are explicitly closed after the copying has complete; the caller is expected to do that as well, since there may be occasions when there is more to be written to the output, or the input is to be rewound and reused, or whatever.
readBufferSize
- how much data to read in each requestin
- the sourceout
- the destinationjava.io.IOException
- thrown if the copying fails for any reasonpublic static final void copy(int readBufferSize, java.io.InputStream in, java.io.OutputStream out, long count) throws java.io.IOException
Copy the specified number of bytes from the current position of the input stream to an output stream.
The data is copied in chunks rather than as individual bytes, but the input and output
streams are used as is, and no BufferedInputStream
or BufferedOutputStream
is inserted; the caller
is expected to do that if maximum performance is desired.
Also, neither the input nor the output streams are explicitly closed after the copying has complete; the caller is expected to do that as well, since there may be occasions when there is more to be written to the output, or the input is to be rewound and reused, or whatever.
in
- the sourceout
- the destinationcount
- the number of bytes to copyreadBufferSize
- how much data to read in each requestjava.io.IOException
- thrown if the copying fails for any reasonpublic static final void copy(java.lang.String inFile, java.lang.String outFile) throws java.io.IOException
Copy an entire input file to an output file.
inFile
- the sourceoutFile
- the destinationjava.io.IOException
- thrown if the copying fails for any reasonpublic static final void copy(java.lang.String inFile, java.lang.String outFile, int readBufferSize, int bufferedInputStreamSizeForFileCopy, int bufferedOutputStreamSizeForFileCopy) throws java.io.IOException
Copy an entire input file to an output file.
inFile
- the sourceoutFile
- the destinationreadBufferSize
- how much data to read in each requestbufferedInputStreamSizeForFileCopy
- the buffered input stream size (or zero if unbuffered)bufferedOutputStreamSizeForFileCopy
- and the buffered output stream size (or zero if unbuffered)java.io.IOException
- thrown if the copying fails for any reasonpublic static final void copyByteSwapped(java.io.InputStream in, java.io.OutputStream out, long count) throws java.io.IOException
Copy the specified even number of bytes from the current position of the input stream to an output stream, swapping adjacent pairs of bytes.
The data is copied in chunks rather than as individual bytes, but the input and output
streams are used as is, and no BufferedInputStream
or BufferedOutputStream
is inserted; the caller
is expected to do that if maximum performance is desired.
Also, neither the input nor the output streams are explicitly closed after the copying has complete; the caller is expected to do that as well, since there may be occasions when there is more to be written to the output, or the input is to be rewound and reused, or whatever.
in
- the sourceout
- the destinationcount
- the number of bytes to copyjava.io.IOException
- thrown if the copying fails for any reasonpublic static final void copyByteSwapped(int readBufferSize, java.io.InputStream in, java.io.OutputStream out, long count) throws java.io.IOException
Copy the specified even number of bytes from the current position of the input stream to an output stream, swapping adjacent pairs of bytes.
The data is copied in chunks rather than as individual bytes, but the input and output
streams are used as is, and no BufferedInputStream
or BufferedOutputStream
is inserted; the caller
is expected to do that if maximum performance is desired.
Also, neither the input nor the output streams are explicitly closed after the copying has complete; the caller is expected to do that as well, since there may be occasions when there is more to be written to the output, or the input is to be rewound and reused, or whatever.
readBufferSize
- how much data to read in each requestin
- the sourceout
- the destinationcount
- the number of bytes to copyjava.io.IOException
- thrown if the copying fails for any reasonpublic static void main(java.lang.String[] arg)
Copy one file to another.
arg
- array of two or five strings - input file, output file,
optionally the copy buffer size,
the buffered input stream size (or zero if unbuffered),
and the buffered output stream size (or zero if unbuffered),public static void skipInsistently(java.io.InputStream in, long length) throws java.io.IOException
Skip as many bytes as requested, unless an exception occurs.
in
- the input stream in which to skip the byteslength
- number of bytes to read (no more and no less)java.io.IOException