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 void |
forceDelete(File file)
Deletes the given file or directory.
|
static byte[] |
getBytes(File f) |
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 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 byte[] getBytes(File f)
public static Collection<File> getUniqueParentDirs(Collection<File> files)
files - Collection of filesCopyright © 2018. All rights reserved.