public enum IOUtils extends Enum<IOUtils>
Modifier and Type | Method and Description |
---|---|
static void |
closeQuietly(Closeable is,
org.apache.commons.logging.Log log)
Closes the given Closeable quietly.
|
static long |
copy(InputStream in,
OutputStream out)
Copies all bytes from the given input stream to the given output stream.
|
static void |
drainInputStream(InputStream in)
Read all remaining data in the stream.
|
static void |
release(Closeable is,
org.apache.commons.logging.Log log)
Releases the given
Closeable especially if it was an instance of
Releasable . |
static byte[] |
toByteArray(InputStream is)
Reads and returns the rest of the given input stream as a byte array.
|
static String |
toString(InputStream is)
Reads and returns the rest of the given input stream as a string.
|
static IOUtils |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static IOUtils[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static IOUtils[] values()
for (IOUtils c : IOUtils.values()) System.out.println(c);
public static IOUtils valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static byte[] toByteArray(InputStream is) throws IOException
IOException
public static String toString(InputStream is) throws IOException
IOException
public static void closeQuietly(Closeable is, org.apache.commons.logging.Log log)
is
- the given closeablelog
- logger used to log any failure should the close failpublic static void release(Closeable is, org.apache.commons.logging.Log log)
Closeable
especially if it was an instance of
Releasable
.
For example, the creation of a ResettableInputStream
would entail
physically opening a file. If the opened file is meant to be closed only
(in a finally block) by the very same code block that created it, then it
is necessary that the release method must not be called while the
execution is made in other stack frames.
In such case, as other stack frames may inadvertently or indirectly call
the close method of the stream, the creator of the stream would need to
explicitly disable the accidental closing via
ResettableInputStream#disableClose()
, so that the release method
becomes the only way to truly close the opened file.
public static long copy(InputStream in, OutputStream out) throws IOException
IOException
- if there is any IO exception during read or write.public static void drainInputStream(InputStream in)
in
- InputStream to read.Copyright © 2013 Amazon Web Services, Inc. All Rights Reserved.