public class StreamCopy extends Object
The code was taken from commons-io:commons-io:2.6 IOUtils and stripped down to the minimum.
| Modifier and Type | Field and Description |
|---|---|
static int |
EOF
Represents the end-of-file (or stream).
|
| Modifier and Type | Method and Description |
|---|---|
static long |
copy(InputStream input,
OutputStream output)
Copies bytes from a
InputStream to an
OutputStream. |
static long |
copy(InputStream input,
OutputStream output,
int bufferSize)
Copies bytes from an
InputStream to an OutputStream using an internal buffer of the
given size. |
static byte[] |
toByteArray(InputStream in)
Copies bytes from a
InputStream to a new byte
array. |
static String |
toString(InputStream in,
Charset charset)
Copies bytes from a
InputStream to a new String
using the given Charset. |
public static final int EOF
public static long copy(InputStream input, OutputStream output) throws IOException
InputStream to an
OutputStream.
This method buffers the input internally, so there is no need to use a
BufferedInputStream.
The buffer size is given by DEFAULT_BUFFER_SIZE.
input - the InputStream to read fromoutput - the OutputStream to write toNullPointerException - if the input or output is nullIOException - if an I/O error occurspublic static long copy(InputStream input, OutputStream output, int bufferSize) throws IOException
InputStream to an OutputStream using an internal buffer of the
given size.
This method buffers the input internally, so there is no need to use a BufferedInputStream.
input - the InputStream to read fromoutput - the OutputStream to write tobufferSize - the bufferSize used to copy from the input to the outputNullPointerException - if the input or output is nullIOException - if an I/O error occurspublic static byte[] toByteArray(InputStream in) throws IOException
InputStream to a new byte
array.input - the InputStream to read fromNullPointerException - if the input is nullIOException - if an I/O error occurspublic static String toString(InputStream in, Charset charset) throws IOException
InputStream to a new String
using the given Charset.input - the InputStream to read fromNullPointerException - if the input is nullIOException - if an I/O error occursCopyright © 2019 mklinger GmbH. All rights reserved.