public final class IOUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
closeQuietly(Closeable closeable)
Null-safe method that calls
Closeable.close() and chokes the IOException. |
static void |
copy(InputStream source,
File destination)
Copies the content of an InputStream into a destination File.
|
static long |
copy(InputStream input,
OutputStream output)
Copies the content of a InputStream into an OutputStream.
|
static long |
copy(InputStream input,
OutputStream output,
int buffersize)
Copies the entire content of the given InputStream into the given OutputStream.
|
static String |
relativePath(File root,
File node)
Computes the path name of a file node relative to a given root node.
|
static void |
requireDirectory(File destination)
Makes sure that the given
File is either a writable directory, or that it does not exist and a directory
can be created at its path. |
public static void copy(InputStream source, File destination) throws IOException
source - the InputStream to copydestination - the target FileIOException - if an error occurspublic static long copy(InputStream input, OutputStream output) throws IOException
input - the InputStream to copyoutput - the target StreamIOException - if an error occurspublic static long copy(InputStream input, OutputStream output, int buffersize) throws IOException
input - the InputStream to copyoutput - the target Streambuffersize - the buffer size to useIOException - if an error occurspublic static String relativePath(File root, File node) throws IOException
/home/cdlflex/custom-ahy and the given node is
/home/cdlflex/custom-ahy/assembly/pom.xml, the returned path name will be assembly/pom.xml.root - the parent nodenode - the file node to compute the relative path fornode relative to rootIOException - when an I/O error occurs during resolving the canonical path of the filespublic static void requireDirectory(File destination) throws IOException, IllegalArgumentException
File is either a writable directory, or that it does not exist and a directory
can be created at its path.
Will throw an exception if the given File is actually an existing file, or the directory is not writabledestination - the directory which to ensure its existence forIOException - if an I/O error occurs e.g. when attempting to create the destination directoryIllegalArgumentException - if the destination is an existing file, or the directory is not writablepublic static void closeQuietly(Closeable closeable)
Closeable.close() and chokes the IOException.closeable - the object to closeCopyright © 2013-2014. All Rights Reserved.