public class StreamUtil
extends java.lang.Object
Constructor and Description |
---|
StreamUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
close(java.io.Closeable closeable)
Closes silently the closable object.
|
static boolean |
compare(java.io.InputStream input1,
java.io.InputStream input2)
Compares the content of two byte streams (
InputStream s). |
static boolean |
compare(java.io.Reader input1,
java.io.Reader input2)
Compares the content of two character streams (
Reader s). |
static FastCharArrayWriter |
copy(javax.activation.DataSource input)
Copies data from
DataSource to a new FastCharArrayWriter and returns this. |
static FastCharArrayWriter |
copy(java.io.InputStream input) |
static FastCharArrayWriter |
copy(java.io.InputStream input,
int count) |
static int |
copy(java.io.InputStream input,
java.io.OutputStream output)
Copies bytes from
InputStream to OutputStream using buffer. |
static int |
copy(java.io.InputStream input,
java.io.OutputStream output,
int count)
Copies specified number of bytes from
InputStream to OutputStream using buffer. |
static FastCharArrayWriter |
copy(java.io.InputStream input,
java.lang.String encoding) |
static FastCharArrayWriter |
copy(java.io.InputStream input,
java.lang.String encoding,
int count)
Copies
InputStream to a new FastCharArrayWriter using buffer and specified encoding. |
static <T extends java.io.Writer> |
copy(java.io.InputStream input,
T output) |
static <T extends java.io.Writer> |
copy(java.io.InputStream input,
T output,
int count) |
static <T extends java.io.Writer> |
copy(java.io.InputStream input,
T output,
java.lang.String encoding) |
static <T extends java.io.Writer> |
copy(java.io.InputStream input,
T output,
java.lang.String encoding,
int count)
Copies
InputStream to Writer using buffer and specified encoding. |
static FastCharArrayWriter |
copy(java.io.Reader input) |
static FastCharArrayWriter |
copy(java.io.Reader input,
int count)
Copies
Reader to a new FastCharArrayWriter using buffer and specified encoding. |
static <T extends java.io.OutputStream> |
copy(java.io.Reader input,
T output) |
static <T extends java.io.OutputStream> |
copy(java.io.Reader input,
T output,
int count) |
static <T extends java.io.OutputStream> |
copy(java.io.Reader input,
T output,
java.lang.String encoding) |
static <T extends java.io.OutputStream> |
copy(java.io.Reader input,
T output,
java.lang.String encoding,
int count)
Copies
Reader to OutputStream using buffer and specified encoding. |
static int |
copy(java.io.Reader input,
java.io.Writer output)
Copies bytes from
Reader to Writer using buffer. |
static int |
copy(java.io.Reader input,
java.io.Writer output,
int count)
Copies specified number of characters from
Reader to Writer using buffer. |
static FastByteArrayOutputStream |
copyToOutputStream(javax.activation.DataSource input)
Copies data from
DataSource to a new FastByteArrayOutputStream and returns this. |
static FastByteArrayOutputStream |
copyToOutputStream(java.io.InputStream input) |
static FastByteArrayOutputStream |
copyToOutputStream(java.io.InputStream input,
int count)
Copies
InputStream to a new FastByteArrayOutputStream using buffer and specified encoding. |
static FastByteArrayOutputStream |
copyToOutputStream(java.io.Reader input) |
static FastByteArrayOutputStream |
copyToOutputStream(java.io.Reader input,
int count) |
static FastByteArrayOutputStream |
copyToOutputStream(java.io.Reader input,
java.lang.String encoding) |
static FastByteArrayOutputStream |
copyToOutputStream(java.io.Reader input,
java.lang.String encoding,
int count)
Copies
Reader to a new FastByteArrayOutputStream using buffer and specified encoding. |
static java.io.InputStreamReader |
inputStreamReadeOf(java.io.InputStream input) |
static java.io.InputStreamReader |
inputStreamReadeOf(java.io.InputStream input,
java.lang.String encoding)
Returns new
InputStreamReader using specified InputStream and encoding. |
static java.io.OutputStreamWriter |
outputStreamWriterOf(java.io.OutputStream output) |
static java.io.OutputStreamWriter |
outputStreamWriterOf(java.io.OutputStream output,
java.lang.String encoding)
Returns new
OutputStreamWriter using specified OutputStream and encoding. |
static byte[] |
readAvailableBytes(java.io.InputStream input)
Reads all available bytes from
InputStream as a byte array. |
static byte[] |
readBytes(java.io.InputStream input) |
static byte[] |
readBytes(java.io.InputStream input,
int count) |
static byte[] |
readBytes(java.io.Reader input) |
static byte[] |
readBytes(java.io.Reader input,
int count) |
static byte[] |
readBytes(java.io.Reader input,
java.lang.String encoding) |
static byte[] |
readBytes(java.io.Reader input,
java.lang.String encoding,
int count) |
static char[] |
readChars(java.io.InputStream input) |
static char[] |
readChars(java.io.InputStream input,
int count) |
static char[] |
readChars(java.io.InputStream input,
java.lang.String encoding) |
static char[] |
readChars(java.io.InputStream input,
java.lang.String encoding,
int count) |
static char[] |
readChars(java.io.Reader input) |
static char[] |
readChars(java.io.Reader input,
int count) |
public static void close(java.io.Closeable closeable)
Flushable
, it
will be flushed first. No exception will be thrown if an I/O error occurs.public static int copy(java.io.Reader input, java.io.Writer output) throws java.io.IOException
Reader
to Writer
using buffer.
Reader
and Writer
don't have to be wrapped to buffered, since copying is already optimized.input
- Reader
to read.output
- Writer
to write to.java.io.IOException
- if there is an error reading or writing.public static int copy(java.io.InputStream input, java.io.OutputStream output) throws java.io.IOException
InputStream
to OutputStream
using buffer.
InputStream
and OutputStream
don't have to be wrapped to buffered,
since copying is already optimized.input
- InputStream
to read.output
- OutputStream
to write to.java.io.IOException
- if there is an error reading or writing.public static int copy(java.io.Reader input, java.io.Writer output, int count) throws java.io.IOException
Reader
to Writer
using buffer.
Reader
and Writer
don't have to be wrapped to buffered, since copying is already optimized.input
- Reader
to read.output
- Writer
to write to.count
- The number of characters to read.java.io.IOException
- if there is an error reading or writing.public static int copy(java.io.InputStream input, java.io.OutputStream output, int count) throws java.io.IOException
InputStream
to OutputStream
using buffer.
InputStream
and OutputStream
don't have to be wrapped to buffered, since copying is already optimized.input
- InputStream
to read.output
- OutputStream
to write to.count
- The number of bytes to read.java.io.IOException
- if there is an error reading or writing.public static byte[] readAvailableBytes(java.io.InputStream input) throws java.io.IOException
InputStream
as a byte array.
Uses InputStream.available()
to determine the size of input stream.
This is the fastest method for reading InputStream
to byte array, but
depends on InputStream
implementation of InputStream.available()
.input
- InputStream
to read.java.io.IOException
- if total read is less than InputStream.available()
;public static <T extends java.io.OutputStream> T copy(java.io.Reader input, T output) throws java.io.IOException
java.io.IOException
copy(Reader, OutputStream, String)
public static <T extends java.io.OutputStream> T copy(java.io.Reader input, T output, int count) throws java.io.IOException
java.io.IOException
copy(Reader, OutputStream, String, int)
public static <T extends java.io.OutputStream> T copy(java.io.Reader input, T output, java.lang.String encoding) throws java.io.IOException
java.io.IOException
copy(Reader, OutputStream, String, int)
public static <T extends java.io.OutputStream> T copy(java.io.Reader input, T output, java.lang.String encoding, int count) throws java.io.IOException
Reader
to OutputStream
using buffer and specified encoding.java.io.IOException
copy(Reader, Writer, int)
public static FastByteArrayOutputStream copyToOutputStream(javax.activation.DataSource input) throws java.io.IOException
DataSource
to a new FastByteArrayOutputStream
and returns this.input
- DataSource
to copy from.FastByteArrayOutputStream
with data from input.java.io.IOException
copyToOutputStream(InputStream)
public static FastByteArrayOutputStream copyToOutputStream(java.io.InputStream input) throws java.io.IOException
java.io.IOException
copyToOutputStream(InputStream, int)
public static FastByteArrayOutputStream copyToOutputStream(java.io.InputStream input, int count) throws java.io.IOException
InputStream
to a new FastByteArrayOutputStream
using buffer and specified encoding.java.io.IOException
copy(InputStream, OutputStream, int)
public static FastByteArrayOutputStream copyToOutputStream(java.io.Reader input) throws java.io.IOException
java.io.IOException
copyToOutputStream(Reader, String)
public static FastByteArrayOutputStream copyToOutputStream(java.io.Reader input, java.lang.String encoding) throws java.io.IOException
java.io.IOException
copyToOutputStream(Reader, String, int)
public static FastByteArrayOutputStream copyToOutputStream(java.io.Reader input, int count) throws java.io.IOException
java.io.IOException
copyToOutputStream(Reader, String, int)
public static FastByteArrayOutputStream copyToOutputStream(java.io.Reader input, java.lang.String encoding, int count) throws java.io.IOException
Reader
to a new FastByteArrayOutputStream
using buffer and specified encoding.java.io.IOException
copy(Reader, OutputStream, String, int)
public static <T extends java.io.Writer> T copy(java.io.InputStream input, T output) throws java.io.IOException
java.io.IOException
copy(InputStream, Writer, String)
public static <T extends java.io.Writer> T copy(java.io.InputStream input, T output, int count) throws java.io.IOException
java.io.IOException
copy(InputStream, Writer, String, int)
public static <T extends java.io.Writer> T copy(java.io.InputStream input, T output, java.lang.String encoding) throws java.io.IOException
java.io.IOException
copy(InputStream, Writer, String, int)
public static <T extends java.io.Writer> T copy(java.io.InputStream input, T output, java.lang.String encoding, int count) throws java.io.IOException
InputStream
to Writer
using buffer and specified encoding.java.io.IOException
copy(Reader, Writer, int)
public static FastCharArrayWriter copy(java.io.InputStream input) throws java.io.IOException
java.io.IOException
copy(InputStream, String)
public static FastCharArrayWriter copy(java.io.InputStream input, int count) throws java.io.IOException
java.io.IOException
copy(InputStream, String, int)
public static FastCharArrayWriter copy(java.io.InputStream input, java.lang.String encoding) throws java.io.IOException
java.io.IOException
copy(InputStream, String, int)
public static FastCharArrayWriter copy(java.io.InputStream input, java.lang.String encoding, int count) throws java.io.IOException
InputStream
to a new FastCharArrayWriter
using buffer and specified encoding.java.io.IOException
copy(InputStream, Writer, String, int)
public static FastCharArrayWriter copy(java.io.Reader input) throws java.io.IOException
java.io.IOException
copy(Reader, int)
public static FastCharArrayWriter copy(java.io.Reader input, int count) throws java.io.IOException
Reader
to a new FastCharArrayWriter
using buffer and specified encoding.java.io.IOException
copy(Reader, Writer, int)
public static FastCharArrayWriter copy(javax.activation.DataSource input) throws java.io.IOException
DataSource
to a new FastCharArrayWriter
and returns this.input
- DataSource
to copy from.FastCharArrayWriter
with data from input.java.io.IOException
copy(InputStream)
public static byte[] readBytes(java.io.InputStream input) throws java.io.IOException
java.io.IOException
readBytes(InputStream, int)
public static byte[] readBytes(java.io.InputStream input, int count) throws java.io.IOException
java.io.IOException
copyToOutputStream(InputStream, int)
public static byte[] readBytes(java.io.Reader input) throws java.io.IOException
java.io.IOException
readBytes(Reader, String)
public static byte[] readBytes(java.io.Reader input, int count) throws java.io.IOException
java.io.IOException
readBytes(Reader, String, int)
public static byte[] readBytes(java.io.Reader input, java.lang.String encoding) throws java.io.IOException
java.io.IOException
readBytes(Reader, String, int)
public static byte[] readBytes(java.io.Reader input, java.lang.String encoding, int count) throws java.io.IOException
java.io.IOException
copyToOutputStream(Reader, String, int)
public static char[] readChars(java.io.Reader input) throws java.io.IOException
java.io.IOException
readChars(Reader, int)
public static char[] readChars(java.io.Reader input, int count) throws java.io.IOException
java.io.IOException
copy(Reader, int)
public static char[] readChars(java.io.InputStream input) throws java.io.IOException
java.io.IOException
readChars(InputStream, int)
public static char[] readChars(java.io.InputStream input, java.lang.String encoding) throws java.io.IOException
java.io.IOException
readChars(InputStream, String, int)
public static char[] readChars(java.io.InputStream input, int count) throws java.io.IOException
java.io.IOException
readChars(InputStream, String, int)
public static char[] readChars(java.io.InputStream input, java.lang.String encoding, int count) throws java.io.IOException
java.io.IOException
copy(InputStream, String, int)
public static boolean compare(java.io.InputStream input1, java.io.InputStream input2) throws java.io.IOException
InputStream
s).true
if the content of the first InputStream
is equal
to the content of the second InputStream
.java.io.IOException
public static boolean compare(java.io.Reader input1, java.io.Reader input2) throws java.io.IOException
Reader
s).true
if the content of the first Reader
is equal
to the content of the second Reader
.java.io.IOException
public static java.io.InputStreamReader inputStreamReadeOf(java.io.InputStream input) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
inputStreamReadeOf(InputStream, String)
public static java.io.InputStreamReader inputStreamReadeOf(java.io.InputStream input, java.lang.String encoding) throws java.io.UnsupportedEncodingException
InputStreamReader
using specified InputStream
and encoding.input
- InputStream
encoding
- Encoding as String
to use for InputStreamReader
.InputStreamReader
java.io.UnsupportedEncodingException
- if encoding is not valid.public static java.io.OutputStreamWriter outputStreamWriterOf(java.io.OutputStream output) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
outputStreamWriterOf(OutputStream, String)
public static java.io.OutputStreamWriter outputStreamWriterOf(java.io.OutputStream output, java.lang.String encoding) throws java.io.UnsupportedEncodingException
OutputStreamWriter
using specified OutputStream
and encoding.output
- OutputStream
encoding
- Encoding as String
to use for OutputStreamWriter
.OutputStreamWriter
java.io.UnsupportedEncodingException
- if encoding is not valid.Copyright © 2003-present Jodd Team