public class FileUtils
extends java.lang.Object
| Constructor and Description |
|---|
FileUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
closeQuietly(java.io.Closeable closeable)
Closes a closeable quietly, i.e., without exception.
|
static void |
copyFile(java.io.File target,
java.io.File source)
Copies a file.
|
static void |
copyToFile(java.io.File file,
java.io.InputStream in)
Copies the contents of
in at the current position to file. |
static void |
copyToFile(java.io.File file,
java.io.InputStream in,
byte[] buffer)
Copies the contents of
in at the current position to file. |
static void |
createIfNotExists(java.io.File file)
Creates a (physical) file if it does not exist.
|
static java.io.File |
createTmpDir(java.lang.String name)
Creates a temporary directory and deletes an existing one if it already exists.
|
static java.io.File |
createTmpDir(java.lang.String name,
boolean deleteIfExists)
Creates a temporary directory.
|
static boolean |
isFileURI(java.net.URI uri)
Returns whether the given
uri is a file URI as returned, e.g., by a File. |
static boolean |
isFileURL(java.net.URL url)
Returns whether the given
url is a JAR URL as returned, e.g., by a classloader. |
public static boolean isFileURI(java.net.URI uri)
uri is a file URI as returned, e.g., by a File.uri - the URI (ignored if null)true for a file URI, false elsepublic static boolean isFileURL(java.net.URL url)
url is a JAR URL as returned, e.g., by a classloader.url - the URL (ignored if null)true for a JAR URL, false elsepublic static void copyFile(java.io.File target,
java.io.File source)
throws java.io.IOException
target - the target filesource - the source filejava.io.IOException - in any case of I/O problem, trying to close the involved files before end if possiblepublic static void copyToFile(java.io.File file,
java.io.InputStream in)
throws java.io.IOException
in at the current position to file.
Does not attempt to close in. Uses a default buffer of size 1024.file - the file to write toin - the input streamjava.io.IOException - in any case of I/O problem, trying to close file before end if possiblepublic static void copyToFile(java.io.File file,
java.io.InputStream in,
byte[] buffer)
throws java.io.IOException
in at the current position to file.
Does not attempt to close in. Uses a default buffer of size 1024.file - the file to write toin - the input streambuffer - a copy buffer (if null a default one of size 1024 is used)java.io.IOException - in any case of I/O problem, trying to close file before if possiblepublic static void closeQuietly(java.io.Closeable closeable)
closeable - the closeablepublic static void createIfNotExists(java.io.File file)
file - the file (may be null, ignored then)public static java.io.File createTmpDir(java.lang.String name)
name - the name of the directory within the standard temporary folderpublic static java.io.File createTmpDir(java.lang.String name,
boolean deleteIfExists)
name - the name of the directory within the standard temporary folderdeleteIfExists - delete an existing one if it already existsCopyright © 2009 - 2018 SSE. All Rights Reserved.