public final class IOUtils
extends java.lang.Object
Modifier and Type | Method | Description |
---|---|---|
static java.io.IOException |
closeAndLogException(java.io.Closeable closeable,
org.apache.commons.logging.Log logger,
java.lang.String resourceName,
java.io.IOException initialException) |
Try to close an IO resource and log and return if there was an exception.
|
static void |
closeQuietly(java.io.Closeable closeable) |
Null safe close of the given
Closeable suppressing any exception. |
static long |
copy(java.io.InputStream input,
java.io.OutputStream output) |
Copies all the contents from the given input stream to the given output stream.
|
static long |
populateBuffer(java.io.InputStream in,
byte[] buffer) |
Populates the given buffer with data read from the input stream.
|
static byte[] |
toByteArray(java.io.InputStream in) |
Reads the input stream and returns its contents as a byte array.
|
public static byte[] toByteArray(java.io.InputStream in) throws java.io.IOException
in
- the input stream to read from.java.io.IOException
- if an I/O error occurspublic static long copy(java.io.InputStream input, java.io.OutputStream output) throws java.io.IOException
input
- the input streamoutput
- the output streamjava.io.IOException
- if an I/O error occurspublic static long populateBuffer(java.io.InputStream in, byte[] buffer) throws java.io.IOException
in
- the input stream to read frombuffer
- the buffer to filljava.io.IOException
- if an I/O error occurspublic static void closeQuietly(java.io.Closeable closeable)
Closeable
suppressing any exception.closeable
- to be closedpublic static java.io.IOException closeAndLogException(java.io.Closeable closeable, org.apache.commons.logging.Log logger, java.lang.String resourceName, java.io.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. All rights reserved.