public final class IOUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static IOException |
closeAndLogException(Closeable closeable,
org.apache.commons.logging.Log logger,
String resourceName,
IOException initialException)
Try to close an IO resource and log and return if there was an exception.
|
static void |
closeQuietly(Closeable closeable)
Null safe close of the given
Closeable suppressing any exception. |
static long |
copy(InputStream input,
OutputStream output)
Copies all the contents from the given input stream to the given output stream.
|
static long |
populateBuffer(InputStream in,
byte[] buffer)
Populates the given buffer with data read from the input stream.
|
static byte[] |
toByteArray(InputStream in)
Reads the input stream and returns its contents as a byte array.
|
public static byte[] toByteArray(InputStream in) throws IOException
in - the input stream to read from.IOException - if an I/O error occurspublic static long copy(InputStream input, OutputStream output) throws IOException
input - the input streamoutput - the output streamIOException - if an I/O error occurspublic static long populateBuffer(InputStream in, byte[] buffer) throws IOException
in - the input stream to read frombuffer - the buffer to fillIOException - if an I/O error occurspublic static void closeQuietly(Closeable closeable)
Closeable suppressing any exception.closeable - to be closedpublic static IOException closeAndLogException(Closeable closeable, org.apache.commons.logging.Log logger, String resourceName, IOException initialException)
An exception is only returned if the IOException passed in is null.
closeable - to be closedlogger - the logger to be used so that logging appears under that log instanceresourceName - the name to appear in the log outputinitialException - to be closedCopyright © 2002–2018 The Apache Software Foundation. All rights reserved.