public final class IOUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static void |
closeQuietly(java.io.Closeable closeable)
Null-safe method that calls
Closeable.close() and chokes the IOException. |
static void |
copy(java.io.InputStream source,
java.io.File destination)
Copies the content of an InputStream into a destination File.
|
static long |
copy(java.io.InputStream input,
java.io.OutputStream output)
Copies the content of a InputStream into an OutputStream.
|
static long |
copy(java.io.InputStream input,
java.io.OutputStream output,
int buffersize)
Copies the entire content of the given InputStream into the given OutputStream.
|
static java.io.File[] |
filesContainedIn(java.io.File source)
Given a source File, return its direct descendants if the File is a directory.
|
static java.lang.String |
relativePath(java.io.File root,
java.io.File node)
Computes the path name of a file node relative to a given root node.
|
static void |
requireDirectory(java.io.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(java.io.InputStream source,
java.io.File destination)
throws java.io.IOException
source - the InputStream to copydestination - the target Filejava.io.IOException - if an error occurspublic static long copy(java.io.InputStream input,
java.io.OutputStream output)
throws java.io.IOException
input - the InputStream to copyoutput - the target Streamjava.io.IOException - if an error occurspublic static long copy(java.io.InputStream input,
java.io.OutputStream output,
int buffersize)
throws java.io.IOException
input - the InputStream to copyoutput - the target Streambuffersize - the buffer size to usejava.io.IOException - if an error occurspublic static java.lang.String relativePath(java.io.File root,
java.io.File node)
throws java.io.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 rootjava.io.IOException - when an I/O error occurs during resolving the canonical path of the filespublic static void requireDirectory(java.io.File destination)
throws java.io.IOException,
java.lang.IllegalArgumentException
File is either a writable directory, or that it does not exist and a directory
can be created at its path.
File is actually an existing file, or the directory is not writabledestination - the directory which to ensure its existence forjava.io.IOException - if an I/O error occurs e.g. when attempting to create the destination directoryjava.lang.IllegalArgumentException - if the destination is an existing file, or the directory is not writablepublic static void closeQuietly(java.io.Closeable closeable)
Closeable.close() and chokes the IOException.closeable - the object to closepublic static java.io.File[] filesContainedIn(java.io.File source)
source - File or folder to be examinedCopyright © 2013-2018. All Rights Reserved.