public class StreamUtils
extends java.lang.Object
InputStream and
OutputStream) and character (Reader and
Writer) streams.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BUFFER_SIZE
The default size of the byte buffer used in the
copy(java.io.OutputStream, java.io.InputStream, int) methods. |
| Constructor and Description |
|---|
StreamUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
copy(java.io.OutputStream dest,
java.io.InputStream source)
Copy with default buffer size.
|
static void |
copy(java.io.OutputStream dest,
java.io.InputStream source,
int bufSize)
Copy data from an
InputStream to an OutputStream until an
end-of-stream is reached on the source InputStream. |
static void |
copy(java.io.OutputStream dest,
java.net.URL source)
Copy from
URL stream. |
static void |
copy(java.io.Writer dest,
java.io.Reader source,
int bufSize)
Copy data from an
Reader to an Writer until an
end-of-stream is reached on the source Reader. |
static void |
extractJar(java.io.File dest,
java.io.InputStream is)
Expand a Jar input stream.
|
static byte[] |
read(java.io.InputStream source)
Read the contents of the given InputStream into a byte array.
|
static byte[] |
read(java.net.URL input)
Read the contents of the given URL into a byte array.
|
static java.lang.Object |
readObj(java.io.InputStream is) |
static void |
write(java.io.OutputStream dest,
java.io.Serializable src)
Write a
Serializable object to an output stream using the
ObjectOutputStream mechanism. |
public static final int DEFAULT_BUFFER_SIZE
copy(java.io.OutputStream, java.io.InputStream, int) methods.public static byte[] read(java.net.URL input)
throws java.io.IOException
input - the URL to readjava.io.IOException - in case of I/O errorpublic static byte[] read(java.io.InputStream source)
throws java.io.IOException
input - the InputStream to readjava.io.IOException - in case of I/O errorpublic static void copy(java.io.OutputStream dest,
java.io.InputStream source,
int bufSize)
throws java.io.IOException
InputStream to an OutputStream until an
end-of-stream is reached on the source InputStream. This method
does not attempt to close either the source or the destination
stream.dest - destination OutputStreamsource - source InputStreambufSize - write buffer sizejava.io.IOException - in case of I/O errorpublic static void copy(java.io.Writer dest,
java.io.Reader source,
int bufSize)
throws java.io.IOException
Reader to an Writer until an
end-of-stream is reached on the source Reader. This method does
not attempt to close either the source or the destination
stream.dest - destination Writersource - source ReaderbufSize - write buffer sizejava.io.IOException - in case of I/O errorpublic static void copy(java.io.OutputStream dest,
java.io.InputStream source)
throws java.io.IOException
java.io.IOExceptioncopy(java.io.OutputStream, java.io.InputStream),
DEFAULT_BUFFER_SIZEpublic static void copy(java.io.OutputStream dest,
java.net.URL source)
throws java.io.IOException
URL stream.dest - destination OutputStreamsource - source URLjava.io.IOExceptioncopy(java.io.OutputStream, java.io.InputStream, int)public static void write(java.io.OutputStream dest,
java.io.Serializable src)
throws java.io.IOException
Serializable object to an output stream using the
ObjectOutputStream mechanism.dest - destination OutputStreamsrc - source Serializablejava.io.IOExceptionpublic static java.lang.Object readObj(java.io.InputStream is)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic static void extractJar(java.io.File dest,
java.io.InputStream is)
throws java.io.IOException
java.io.IOException