public class StreamUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
ioBufferSize
The io buffer size.
|
| Constructor and Description |
|---|
StreamUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
close(InputStream in)
Closes an input stream and releases any system resources associated with
this stream.
|
static void |
close(OutputStream out)
Closes an output stream and releases any system resources associated with
this stream.
|
static void |
close(Reader in)
Closes a character-input stream and releases any system resources
associated with this stream.
|
static void |
close(Writer out)
Closes a character-output stream and releases any system resources
associated with this stream.
|
static boolean |
compare(InputStream input1,
InputStream input2)
Compares the content of two byte streams.
|
static boolean |
compare(Reader input1,
Reader input2)
Compares the content of two character streams.
|
static int |
copy(InputStream input,
OutputStream output)
Copies input stream to output stream using buffer.
|
static int |
copy(InputStream input,
OutputStream output,
int byteCount)
Copies specified number of bytes from input stream to output stream using
buffer.
|
static void |
copy(InputStream input,
Writer output)
Copies input stream to writer using buffer.
|
static void |
copy(InputStream input,
Writer output,
int byteCount)
Copies specified number of bytes from input stream to writer using
buffer.
|
static void |
copy(InputStream input,
Writer output,
String encoding)
Copies input stream to writer using buffer and specified encoding.
|
static void |
copy(InputStream input,
Writer output,
String encoding,
int byteCount)
Copies specified number of bytes from input stream to writer using buffer
and specified encoding.
|
static void |
copy(Reader input,
OutputStream output)
Copies reader to output stream using buffer.
|
static void |
copy(Reader input,
OutputStream output,
int charCount)
Copies specified number of characters from reader to output stream using
buffer.
|
static void |
copy(Reader input,
OutputStream output,
String encoding)
Copies reader to output stream using buffer and specified encoding.
|
static void |
copy(Reader input,
OutputStream output,
String encoding,
int charCount)
Copies specified number of characters from reader to output stream using
buffer and specified encoding.
|
static int |
copy(Reader input,
Writer output)
Copies reader to writer using buffer.
|
static int |
copy(Reader input,
Writer output,
int charCount)
Copies specified number of characters from reader to writer using buffer.
|
static byte[] |
readAvailableBytes(InputStream in)
Reads all available bytes from InputStream as a byte array.
|
static byte[] |
readBytes(InputStream input)
Read bytes.
|
static byte[] |
readBytes(InputStream input,
int byteCount)
Read bytes.
|
static byte[] |
readBytes(Reader input)
Read bytes.
|
static byte[] |
readBytes(Reader input,
int byteCount)
Read bytes.
|
static byte[] |
readBytes(Reader input,
String encoding)
Read bytes.
|
static byte[] |
readBytes(Reader input,
String encoding,
int byteCount)
Read bytes.
|
static char[] |
readChars(InputStream input)
Read chars.
|
static char[] |
readChars(InputStream input,
int charCount)
Read chars.
|
static char[] |
readChars(InputStream input,
String encoding)
Read chars.
|
static char[] |
readChars(InputStream input,
String encoding,
int charCount)
Read chars.
|
static char[] |
readChars(Reader input)
Read chars.
|
static char[] |
readChars(Reader input,
int charCount)
Read chars.
|
public static void close(InputStream in)
in - the inpublic static void close(OutputStream out)
out - the outpublic static void close(Reader in)
in - the inpublic static void close(Writer out)
out - the outpublic static int copy(InputStream input, OutputStream output) throws IOException
input - the inputoutput - the outputIOException - Signals that an I/O exception has occurred.public static int copy(InputStream input, OutputStream output, int byteCount) throws IOException
input - the inputoutput - the outputbyteCount - the byte countIOException - Signals that an I/O exception has occurred.public static void copy(InputStream input, Writer output) throws IOException
input - the inputoutput - the outputIOException - Signals that an I/O exception has occurred.public static void copy(InputStream input, Writer output, int byteCount) throws IOException
input - the inputoutput - the outputbyteCount - the byte countIOException - Signals that an I/O exception has occurred.public static void copy(InputStream input, Writer output, String encoding) throws IOException
input - the inputoutput - the outputencoding - the encodingIOException - Signals that an I/O exception has occurred.public static void copy(InputStream input, Writer output, String encoding, int byteCount) throws IOException
input - the inputoutput - the outputencoding - the encodingbyteCount - the byte countIOException - Signals that an I/O exception has occurred.public static int copy(Reader input, Writer output) throws IOException
input - the inputoutput - the outputIOException - Signals that an I/O exception has occurred.public static int copy(Reader input, Writer output, int charCount) throws IOException
input - the inputoutput - the outputcharCount - the char countIOException - Signals that an I/O exception has occurred.public static void copy(Reader input, OutputStream output) throws IOException
input - the inputoutput - the outputIOException - Signals that an I/O exception has occurred.public static void copy(Reader input, OutputStream output, int charCount) throws IOException
input - the inputoutput - the outputcharCount - the char countIOException - Signals that an I/O exception has occurred.public static void copy(Reader input, OutputStream output, String encoding) throws IOException
input - the inputoutput - the outputencoding - the encodingIOException - Signals that an I/O exception has occurred.public static void copy(Reader input, OutputStream output, String encoding, int charCount) throws IOException
input - the inputoutput - the outputencoding - the encodingcharCount - the char countIOException - Signals that an I/O exception has occurred.public static byte[] readAvailableBytes(InputStream in) throws IOException
in.available() to determine the size of input stream. This
is the fastest method for reading input stream to byte array, but depends
on stream implementation of available(). Buffered
internally.in - the inIOException - Signals that an I/O exception has occurred.public static byte[] readBytes(InputStream input) throws IOException
input - the inputIOException - Signals that an I/O exception has occurred.public static byte[] readBytes(InputStream input, int byteCount) throws IOException
input - the inputbyteCount - the byte countIOException - Signals that an I/O exception has occurred.public static byte[] readBytes(Reader input) throws IOException
input - the inputIOException - Signals that an I/O exception has occurred.public static byte[] readBytes(Reader input, int byteCount) throws IOException
input - the inputbyteCount - the byte countIOException - Signals that an I/O exception has occurred.public static byte[] readBytes(Reader input, String encoding) throws IOException
input - the inputencoding - the encodingIOException - Signals that an I/O exception has occurred.public static byte[] readBytes(Reader input, String encoding, int byteCount) throws IOException
input - the inputencoding - the encodingbyteCount - the byte countIOException - Signals that an I/O exception has occurred.public static char[] readChars(InputStream input) throws IOException
input - the inputIOException - Signals that an I/O exception has occurred.public static char[] readChars(InputStream input, int charCount) throws IOException
input - the inputcharCount - the char countIOException - Signals that an I/O exception has occurred.public static char[] readChars(InputStream input, String encoding) throws IOException
input - the inputencoding - the encodingIOException - Signals that an I/O exception has occurred.public static char[] readChars(InputStream input, String encoding, int charCount) throws IOException
input - the inputencoding - the encodingcharCount - the char countIOException - Signals that an I/O exception has occurred.public static char[] readChars(Reader input) throws IOException
input - the inputIOException - Signals that an I/O exception has occurred.public static char[] readChars(Reader input, int charCount) throws IOException
input - the inputcharCount - the char countIOException - Signals that an I/O exception has occurred.public static boolean compare(InputStream input1, InputStream input2) throws IOException
input1 - the input1input2 - the input2true if the content of the first stream is equal to
the content of the second stream.IOException - Signals that an I/O exception has occurred.public static boolean compare(Reader input1, Reader input2) throws IOException
input1 - the input1input2 - the input2true if the content of the first stream is equal to
the content of the second stream.IOException - Signals that an I/O exception has occurred.Copyright © 2016 utils4j. All Rights Reserved.