public abstract class StreamUtils extends Object
FileCopyUtils
except that all affected streams are
left open when done. All copy methods use a block size of 4096 bytes.
Mainly for use within the framework, but also useful for application code.
FileCopyUtils
Modifier and Type | Field and Description |
---|---|
static int |
BUFFER_SIZE |
Constructor and Description |
---|
StreamUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
copy(byte[] in,
OutputStream out)
Copy the contents of the given byte array to the given OutputStream.
|
static int |
copy(InputStream in,
OutputStream out)
Copy the contents of the given InputStream to the given OutputStream.
|
static void |
copy(String in,
Charset charset,
OutputStream out)
Copy the contents of the given String to the given output OutputStream.
|
static byte[] |
copyToByteArray(InputStream in)
Copy the contents of the given InputStream into a new byte array.
|
static String |
copyToString(InputStream in,
Charset charset)
Copy the contents of the given InputStream into a String.
|
static InputStream |
nonClosing(InputStream in)
Returns a variant of the given
InputStream where calling
close() has no effect. |
static OutputStream |
nonClosing(OutputStream out)
Returns a variant of the given
OutputStream where calling
close() has no effect. |
public static final int BUFFER_SIZE
public static byte[] copyToByteArray(InputStream in) throws IOException
in
- the stream to copy fromIOException
- in case of I/O errorspublic static String copyToString(InputStream in, Charset charset) throws IOException
in
- the InputStream to copy fromIOException
- in case of I/O errorspublic static void copy(byte[] in, OutputStream out) throws IOException
in
- the byte array to copy fromout
- the OutputStream to copy toIOException
- in case of I/O errorspublic static void copy(String in, Charset charset, OutputStream out) throws IOException
in
- the String to copy fromcharset
- the Charsetout
- the OutputStream to copy toIOException
- in case of I/O errorspublic static int copy(InputStream in, OutputStream out) throws IOException
in
- the InputStream to copy fromout
- the OutputStream to copy toIOException
- in case of I/O errorspublic static InputStream nonClosing(InputStream in)
InputStream
where calling
close()
has no effect.in
- the InputStream to decoratepublic static OutputStream nonClosing(OutputStream out)
OutputStream
where calling
close()
has no effect.out
- the OutputStream to decorate