Class CopyStream
A class for copying an entire input stream to an output stream.
-
Method Summary
Modifier and TypeMethodDescriptionstatic final void
copy
(int readBufferSize, InputStream in, OutputStream out) Copy an entire input stream to an output stream.static final void
copy
(int readBufferSize, InputStream in, OutputStream out, long count) Copy the specified number of bytes from the current position of the input stream to an output stream.static final void
Copy an entire input file to an output file.static final void
copy
(File inFile, File outFile, int readBufferSize, int bufferedInputStreamSizeForFileCopy, int bufferedOutputStreamSizeForFileCopy) Copy an entire input file to an output file.static final void
copy
(InputStream in, OutputStream out) Copy an entire input stream to an output stream.static final void
copy
(InputStream in, OutputStream out, long count) Copy the specified number of bytes from the current position of the input stream to an output stream.static final void
Copy an entire input file to an output file.static final void
copy
(String inFile, String outFile, int readBufferSize, int bufferedInputStreamSizeForFileCopy, int bufferedOutputStreamSizeForFileCopy) Copy an entire input file to an output file.static final void
copyByteSwapped
(int readBufferSize, InputStream in, 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 final void
copyByteSwapped
(InputStream in, 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
Copy one file to another.static void
skipInsistently
(InputStream in, long length) Skip as many bytes as requested, unless an exception occurs.
-
Method Details
-
skipInsistently
Skip as many bytes as requested, unless an exception occurs.
- Parameters:
in
- the input stream in which to skip the byteslength
- number of bytes to read (no more and no less)- Throws:
IOException
-
copyByteSwapped
public static final void copyByteSwapped(int readBufferSize, InputStream in, OutputStream out, long count) throws 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
orBufferedOutputStream
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.
- Parameters:
readBufferSize
- how much data to read in each requestin
- the sourceout
- the destinationcount
- the number of bytes to copy- Throws:
IOException
- thrown if the copying fails for any reason
-
copyByteSwapped
public static final void copyByteSwapped(InputStream in, OutputStream out, long count) throws 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
orBufferedOutputStream
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.
- Parameters:
in
- the sourceout
- the destinationcount
- the number of bytes to copy- Throws:
IOException
- thrown if the copying fails for any reason
-
copy
public static final void copy(int readBufferSize, InputStream in, OutputStream out, long count) throws 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
orBufferedOutputStream
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.
- Parameters:
readBufferSize
- how much data to read in each requestin
- the sourceout
- the destinationcount
- the number of bytes to copy- Throws:
IOException
- thrown if the copying fails for any reason
-
copy
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
orBufferedOutputStream
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.
- Parameters:
in
- the sourceout
- the destinationcount
- the number of bytes to copy- Throws:
IOException
- thrown if the copying fails for any reason
-
copy
public static final void copy(int readBufferSize, InputStream in, OutputStream out) throws 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
orBufferedOutputStream
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.
- Parameters:
readBufferSize
- how much data to read in each requestin
- the sourceout
- the destination- Throws:
IOException
- thrown if the copying fails for any reason
-
copy
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
orBufferedOutputStream
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.
- Parameters:
in
- the sourceout
- the destination- Throws:
IOException
- thrown if the copying fails for any reason
-
copy
public static final void copy(File inFile, File outFile, int readBufferSize, int bufferedInputStreamSizeForFileCopy, int bufferedOutputStreamSizeForFileCopy) throws IOException Copy an entire input file to an output file.
- Parameters:
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)- Throws:
IOException
- thrown if the copying fails for any reason
-
copy
public static final void copy(String inFile, String outFile, int readBufferSize, int bufferedInputStreamSizeForFileCopy, int bufferedOutputStreamSizeForFileCopy) throws IOException Copy an entire input file to an output file.
- Parameters:
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)- Throws:
IOException
- thrown if the copying fails for any reason
-
copy
Copy an entire input file to an output file.
- Parameters:
inFile
- the sourceoutFile
- the destination- Throws:
IOException
- thrown if the copying fails for any reason
-
copy
Copy an entire input file to an output file.
- Parameters:
inFile
- the sourceoutFile
- the destination- Throws:
IOException
- thrown if the copying fails for any reason
-
main
Copy one file to another.
- Parameters:
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),
-