|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.io.IOUtils
public final class IOUtils
General IO Stream manipulation.
This class provides static utility methods for input/output operations.
The closeQuietly methods are expected to be used when an IOException would be meaningless. This is usually when in a catch block for an IOException.
The toString and toByteArray methods all rely on CopyUtils.copy methods in the current implementation.
Origin of code: Apache Avalon (Excalibur)
Constructor Summary | |
---|---|
IOUtils()
Instances should NOT be constructed in standard programming. |
Method Summary | |
---|---|
static void |
closeQuietly(InputStream input)
Unconditionally close an InputStream . |
static void |
closeQuietly(OutputStream output)
Unconditionally close an OutputStream . |
static void |
closeQuietly(Reader input)
Unconditionally close an Reader . |
static void |
closeQuietly(Writer output)
Unconditionally close an Writer . |
static boolean |
contentEquals(InputStream input1,
InputStream input2)
Compare the contents of two Streams to determine if they are equal or not. |
static byte[] |
toByteArray(InputStream input)
Get the contents of an InputStream as a byte[] . |
static byte[] |
toByteArray(Reader input)
Get the contents of a Reader as a byte[] . |
static byte[] |
toByteArray(String input)
Get the contents of a String as a byte[] . |
static String |
toString(byte[] input)
Get the contents of a byte[] as a String. |
static String |
toString(byte[] input,
String encoding)
Get the contents of a byte[] as a String. |
static String |
toString(InputStream input)
Get the contents of an InputStream as a String. |
static String |
toString(InputStream input,
String encoding)
Get the contents of an InputStream as a String. |
static String |
toString(Reader input)
Get the contents of a Reader as a String. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IOUtils()
Method Detail |
---|
public static void closeQuietly(Reader input)
Reader
.
Equivalent to Reader.close()
, except any exceptions will be ignored.
input
- A (possibly null) Readerpublic static void closeQuietly(Writer output)
Writer
.
Equivalent to Writer.close()
, except any exceptions will be ignored.
output
- A (possibly null) Writerpublic static void closeQuietly(OutputStream output)
OutputStream
.
Equivalent to OutputStream.close()
, except any exceptions will be ignored.
output
- A (possibly null) OutputStreampublic static void closeQuietly(InputStream input)
InputStream
.
Equivalent to InputStream.close()
, except any exceptions will be ignored.
input
- A (possibly null) InputStreampublic static String toString(InputStream input) throws IOException
InputStream
as a String.
The platform's default encoding is used for the byte-to-char conversion.
input
- the InputStream
to read from
String
IOException
- In case of an I/O problempublic static String toString(InputStream input, String encoding) throws IOException
InputStream
as a String.
input
- the InputStream
to read fromencoding
- The name of a supported character encoding. See the
IANA
Charset Registry for a list of valid encoding types.
String
IOException
- In case of an I/O problempublic static byte[] toByteArray(InputStream input) throws IOException
InputStream
as a byte[]
.
input
- the InputStream
to read from
IOException
- In case of an I/O problempublic static String toString(Reader input) throws IOException
Reader
as a String.
input
- the Reader
to read from
String
IOException
- In case of an I/O problempublic static byte[] toByteArray(Reader input) throws IOException
Reader
as a byte[]
.
input
- the Reader
to read from
IOException
- In case of an I/O problempublic static byte[] toByteArray(String input) throws IOException
String
as a byte[]
.
input
- the String
to convert
IOException
- In case of an I/O problempublic static String toString(byte[] input) throws IOException
byte[]
as a String.
The platform's default encoding is used for the byte-to-char conversion.
input
- the byte array to read from
String
IOException
- In case of an I/O problempublic static String toString(byte[] input, String encoding) throws IOException
byte[]
as a String.
input
- the byte array to read fromencoding
- The name of a supported character encoding. See the
IANA
Charset Registry for a list of valid encoding types.
String
IOException
- In case of an I/O problempublic static boolean contentEquals(InputStream input1, InputStream input2) throws IOException
input1
- the first streaminput2
- the second stream
IOException
- In case of an I/O problem
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |