public class FileUtil extends Object
| Constructor and Description |
|---|
FileUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
canWriteToDir(File dir) |
static void |
copyAndClose(InputStream in,
File outputFile)
Copies the given stream to a file.
|
static void |
copyFile(File srcFile,
File destFile)
Copies the given file to a new location.
|
static boolean |
copyIfChanged(URL in,
File outputFile) |
static void |
forceDelete(File file)
Deletes the given file or directory.
|
static String |
getExtension(File file)
Returns the extension of a given file or
null if the file has no extension. |
static Collection<File> |
getUniqueParentDirs(Collection<File> files) |
public static void copyFile(File srcFile, File destFile) throws IOException
If the destination file already exists it will be overwritten.
srcFile - source file (not null, must exist).destFile - destination file (not null, parent directory must exist).IOExceptionpublic static boolean copyIfChanged(URL in, File outputFile) throws IOException
IOExceptionpublic static void copyAndClose(InputStream in, File outputFile) throws IOException
If the destination file already exists it will be overwritten.
in - source stream (not null).outputFile - destination file (not null, parent directory must exist).IOExceptionpublic static void forceDelete(File file) throws IOException
IOExceptionpublic static String getExtension(File file)
null if the file has no extension.file - input file (not null).public static boolean canWriteToDir(File dir)
public static Collection<File> getUniqueParentDirs(Collection<File> files)
files - Collection of filesCopyright © 2016. All rights reserved.