public final class StreamUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static Writer |
NULL_WRITER
A dummy writer with empty implementations of
Writer methods. |
| Modifier and Type | Method and Description |
|---|---|
static void |
copy(InputStream in,
OutputStream out,
int bufSize)
Copies all available data from the input stream to the output stream.
|
static void |
copyAndClose(InputStream in,
OutputStream out,
int bufSize)
Copies all available data from the input stream to the output stream.
|
static InputStream |
prefetch(InputStream stream)
Prefetch the entire content of
stream, close it and return
an InputStream to an in-memory ByteArrayInputStream. |
static byte[] |
readFully(InputStream input)
Read the contents of an opened stream until EOF (or an exception is thrown).
|
static char[] |
readFully(Reader input)
Read the contents of an opened reader until EOF (or an exception is thrown).
|
static byte[] |
readFullyAndClose(InputStream input)
Read the contents of an opened stream until EOF (or an exception is thrown).
|
static char[] |
readFullyAndClose(Reader input)
Read the contents of an opened Reader until EOF (or an exception is thrown).
|
public static byte[] readFullyAndClose(InputStream input) throws IOException
input - Input stream to be read.IOException - propagated from the underlying stream.public static byte[] readFully(InputStream input) throws IOException
input - InputStream from which data is to be read.IOException - propagated from the underlying stream.public static char[] readFullyAndClose(Reader input) throws IOException
input - Reader to be read.IOException - propagated from the underlying stream.public static char[] readFully(Reader input) throws IOException
input - Reader from which data will be read.IOException - propagated from the underlying stream.public static InputStream prefetch(InputStream stream) throws IOException
stream, close it and return
an InputStream to an in-memory ByteArrayInputStream. If
stream is already a ByteArrayInputStream, it is
returned immediately.IOExceptionpublic static void copy(InputStream in, OutputStream out, int bufSize) throws IOException
IOExceptionpublic static void copyAndClose(InputStream in, OutputStream out, int bufSize) throws IOException
IOException