public class IOUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
ioBufferSize
Buffer size for various I/O operations.
|
| Constructor and Description |
|---|
IOUtil() |
| 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 (
InputStreams). |
static boolean |
compare(java.io.Reader input1,
java.io.Reader input2)
Compares the content of two character streams (
Readers). |
static java.io.CharArrayWriter |
copy(java.io.InputStream input) |
static java.io.CharArrayWriter |
copy(java.io.InputStream input,
java.nio.charset.Charset encoding) |
static java.io.CharArrayWriter |
copy(java.io.InputStream input,
java.nio.charset.Charset encoding,
int count)
Copies
InputStream to a new CharArrayWriter using buffer and specified encoding. |
static java.io.CharArrayWriter |
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 <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,
java.nio.charset.Charset encoding) |
static <T extends java.io.Writer> |
copy(java.io.InputStream input,
T output,
java.nio.charset.Charset encoding,
int count)
Copies
InputStream to Writer using buffer and specified encoding. |
static <T extends java.io.Writer> |
copy(java.io.InputStream input,
T output,
int count) |
static java.io.CharArrayWriter |
copy(java.io.Reader input) |
static java.io.CharArrayWriter |
copy(java.io.Reader input,
int count)
Copies
Reader to a new CharArrayWriter 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,
java.nio.charset.Charset encoding) |
static <T extends java.io.OutputStream> |
copy(java.io.Reader input,
T output,
java.nio.charset.Charset encoding,
int count)
Copies
Reader to OutputStream using buffer and specified encoding. |
static <T extends java.io.OutputStream> |
copy(java.io.Reader input,
T output,
int count) |
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 java.io.ByteArrayOutputStream |
copyToOutputStream(java.io.InputStream input) |
static java.io.ByteArrayOutputStream |
copyToOutputStream(java.io.InputStream input,
int count)
Copies
InputStream to a new ByteArrayOutputStream using buffer and specified encoding. |
static java.io.ByteArrayOutputStream |
copyToOutputStream(java.io.Reader input) |
static java.io.ByteArrayOutputStream |
copyToOutputStream(java.io.Reader input,
java.nio.charset.Charset encoding) |
static java.io.ByteArrayOutputStream |
copyToOutputStream(java.io.Reader input,
java.nio.charset.Charset encoding,
int count)
Copies
Reader to a new ByteArrayOutputStream using buffer and specified encoding. |
static java.io.ByteArrayOutputStream |
copyToOutputStream(java.io.Reader input,
int count) |
static java.io.InputStreamReader |
inputStreamReadeOf(java.io.InputStream input) |
static java.io.InputStreamReader |
inputStreamReadeOf(java.io.InputStream input,
java.nio.charset.Charset 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.nio.charset.Charset 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,
java.nio.charset.Charset encoding) |
static byte[] |
readBytes(java.io.Reader input,
java.nio.charset.Charset encoding,
int count) |
static byte[] |
readBytes(java.io.Reader input,
int count) |
static char[] |
readChars(java.io.InputStream input) |
static char[] |
readChars(java.io.InputStream input,
java.nio.charset.Charset encoding) |
static char[] |
readChars(java.io.InputStream input,
java.nio.charset.Charset encoding,
int count) |
static char[] |
readChars(java.io.InputStream input,
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.IOExceptioncopy(Reader, OutputStream, Charset)public static <T extends java.io.OutputStream> T copy(java.io.Reader input,
T output,
int count)
throws java.io.IOException
java.io.IOExceptioncopy(Reader, OutputStream, Charset, int)public static <T extends java.io.OutputStream> T copy(java.io.Reader input,
T output,
java.nio.charset.Charset encoding)
throws java.io.IOException
java.io.IOExceptioncopy(Reader, OutputStream, Charset, int)public static <T extends java.io.OutputStream> T copy(java.io.Reader input,
T output,
java.nio.charset.Charset encoding,
int count)
throws java.io.IOException
Reader to OutputStream using buffer and specified encoding.java.io.IOExceptioncopy(Reader, Writer, int)public static java.io.ByteArrayOutputStream copyToOutputStream(java.io.InputStream input)
throws java.io.IOException
java.io.IOExceptioncopyToOutputStream(InputStream, int)public static java.io.ByteArrayOutputStream copyToOutputStream(java.io.InputStream input,
int count)
throws java.io.IOException
InputStream to a new ByteArrayOutputStream using buffer and specified encoding.java.io.IOExceptioncopy(InputStream, OutputStream, int)public static java.io.ByteArrayOutputStream copyToOutputStream(java.io.Reader input)
throws java.io.IOException
java.io.IOExceptioncopyToOutputStream(Reader, Charset)public static java.io.ByteArrayOutputStream copyToOutputStream(java.io.Reader input,
java.nio.charset.Charset encoding)
throws java.io.IOException
java.io.IOExceptioncopyToOutputStream(Reader, Charset, int)public static java.io.ByteArrayOutputStream copyToOutputStream(java.io.Reader input,
int count)
throws java.io.IOException
java.io.IOExceptioncopyToOutputStream(Reader, Charset, int)public static java.io.ByteArrayOutputStream copyToOutputStream(java.io.Reader input,
java.nio.charset.Charset encoding,
int count)
throws java.io.IOException
Reader to a new ByteArrayOutputStream using buffer and specified encoding.java.io.IOExceptioncopy(Reader, OutputStream, Charset, int)public static <T extends java.io.Writer> T copy(java.io.InputStream input,
T output)
throws java.io.IOException
java.io.IOExceptioncopy(InputStream, Writer, Charset)public static <T extends java.io.Writer> T copy(java.io.InputStream input,
T output,
int count)
throws java.io.IOException
java.io.IOExceptioncopy(InputStream, Writer, Charset, int)public static <T extends java.io.Writer> T copy(java.io.InputStream input,
T output,
java.nio.charset.Charset encoding)
throws java.io.IOException
java.io.IOExceptioncopy(InputStream, Writer, Charset, int)public static <T extends java.io.Writer> T copy(java.io.InputStream input,
T output,
java.nio.charset.Charset encoding,
int count)
throws java.io.IOException
InputStream to Writer using buffer and specified encoding.java.io.IOExceptioncopy(Reader, Writer, int)public static java.io.CharArrayWriter copy(java.io.InputStream input)
throws java.io.IOException
java.io.IOExceptioncopy(InputStream, Charset)public static java.io.CharArrayWriter copy(java.io.InputStream input,
int count)
throws java.io.IOException
java.io.IOExceptioncopy(InputStream, Charset, int)public static java.io.CharArrayWriter copy(java.io.InputStream input,
java.nio.charset.Charset encoding)
throws java.io.IOException
java.io.IOExceptioncopy(InputStream, Charset, int)public static java.io.CharArrayWriter copy(java.io.InputStream input,
java.nio.charset.Charset encoding,
int count)
throws java.io.IOException
InputStream to a new CharArrayWriter using buffer and specified encoding.java.io.IOExceptioncopy(InputStream, Writer, Charset, int)public static java.io.CharArrayWriter copy(java.io.Reader input)
throws java.io.IOException
java.io.IOExceptioncopy(Reader, int)public static java.io.CharArrayWriter copy(java.io.Reader input,
int count)
throws java.io.IOException
Reader to a new CharArrayWriter using buffer and specified encoding.java.io.IOExceptioncopy(Reader, Writer, int)public static byte[] readBytes(java.io.InputStream input)
throws java.io.IOException
java.io.IOExceptionreadBytes(InputStream, int)public static byte[] readBytes(java.io.InputStream input,
int count)
throws java.io.IOException
java.io.IOExceptioncopyToOutputStream(InputStream, int)public static byte[] readBytes(java.io.Reader input)
throws java.io.IOException
java.io.IOExceptionreadBytes(Reader, Charset)public static byte[] readBytes(java.io.Reader input,
int count)
throws java.io.IOException
java.io.IOExceptionreadBytes(Reader, Charset, int)public static byte[] readBytes(java.io.Reader input,
java.nio.charset.Charset encoding)
throws java.io.IOException
java.io.IOExceptionreadBytes(Reader, Charset, int)public static byte[] readBytes(java.io.Reader input,
java.nio.charset.Charset encoding,
int count)
throws java.io.IOException
java.io.IOExceptioncopyToOutputStream(Reader, Charset, int)public static char[] readChars(java.io.Reader input)
throws java.io.IOException
java.io.IOExceptionreadChars(Reader, int)public static char[] readChars(java.io.Reader input,
int count)
throws java.io.IOException
java.io.IOExceptioncopy(Reader, int)public static char[] readChars(java.io.InputStream input)
throws java.io.IOException
java.io.IOExceptionreadChars(InputStream, int)public static char[] readChars(java.io.InputStream input,
java.nio.charset.Charset encoding)
throws java.io.IOException
java.io.IOExceptionreadChars(InputStream, Charset, int)public static char[] readChars(java.io.InputStream input,
int count)
throws java.io.IOException
java.io.IOExceptionreadChars(InputStream, Charset, int)public static char[] readChars(java.io.InputStream input,
java.nio.charset.Charset encoding,
int count)
throws java.io.IOException
java.io.IOExceptioncopy(InputStream, Charset, int)public static boolean compare(java.io.InputStream input1,
java.io.InputStream input2)
throws java.io.IOException
InputStreams).true if the content of the first InputStream is equal
to the content of the second InputStream.java.io.IOExceptionpublic static boolean compare(java.io.Reader input1,
java.io.Reader input2)
throws java.io.IOException
Readers).true if the content of the first Reader is equal
to the content of the second Reader.java.io.IOExceptionpublic static java.io.InputStreamReader inputStreamReadeOf(java.io.InputStream input)
inputStreamReadeOf(InputStream, Charset)public static java.io.InputStreamReader inputStreamReadeOf(java.io.InputStream input,
java.nio.charset.Charset encoding)
InputStreamReader using specified InputStream and encoding.input - InputStreamencoding - Encoding as String to use for InputStreamReader.InputStreamReaderpublic static java.io.OutputStreamWriter outputStreamWriterOf(java.io.OutputStream output)
public static java.io.OutputStreamWriter outputStreamWriterOf(java.io.OutputStream output,
java.nio.charset.Charset encoding)
OutputStreamWriter using specified OutputStream and encoding.output - OutputStreamencoding - Encoding as String to use for OutputStreamWriter.OutputStreamWriter