public class StreamUtils extends Object
InputStreams and OutputStreams.| Modifier and Type | Method and Description |
|---|---|
static void |
copy(InputStream in,
OutputStream out)
Copy all bytes from the input stream to the output stream and close both
streams.
|
static void |
copy(InputStream in,
OutputStream out,
int maximumBytes)
Copy all bytes (up to a specified maximum) from the input stream to the
output stream and close both streams.
|
static void |
copy(InputStream in,
OutputStream out,
ProgressReceiver progressReceiver,
long byteCount)
Copy all bytes from the input stream to the output stream and close both
streams.
|
static byte[] |
load(InputStream in)
Load all bytes from an input stream and close it.
|
public static byte[] load(InputStream in) throws IOException
Integer.MAX_VALUE bytes left in the stream.in - The input stream to load.IOException - If an I/O error occurs while loading the bytes or
closing the stream.public static void copy(InputStream in, OutputStream out) throws IOException
in - The input stream to copy from.out - The output stream to copy to.IOException - If an I/O error occurs while copying the bytes or
closing the streams.public static void copy(InputStream in, OutputStream out, int maximumBytes) throws IOException
IOException.in - The input stream to copy from.out - The output stream to copy to.maximumBytes - The maximum number of bytes to allow in the input
stream.IOException - If an I/O error occurs while copying the bytes or
closing the streams, or if the input stream contained
more than the specified number of bytes.public static void copy(InputStream in, OutputStream out, ProgressReceiver progressReceiver, long byteCount) throws IOException, ProgressReceiver.OperationCancelled
in - The input stream to copy from.out - The output stream to copy to.progressReceiver - An optional progress receiver to report copy
progress to.byteCount - The number of bytes in the input stream. If the input
stream contains more bytes, an
IOException is thrown. Specify -1 to
disable a byte limit. If a progress receiver is
specified then this parameter is mandatory.IOException - If an I/O error occurs while copying the bytes or
closing the streams, or if there were more.ProgressReceiver.OperationCancelled - If a progress receiver was
provided and it threw an OperationCancelled exception.Copyright © 2011–2025 pepsoft.org. All rights reserved.