public class FileUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
copy(File src,
File dest,
boolean overrideExisting)
Copy a file to another.
|
static boolean |
deleteDirectory(File file)
Deletes recursively a directory.
|
static File |
getCanonical(File file)
Gets the canonical file of a file even on windows where links are ignored by File.getCanonicalPath().
|
static String |
getExtension(File file)
Gets the extension of a file.
|
static FileOutputStream |
getHiddenCompliantStream(File file)
Gets a FileOutputStream even on a windows hidden file.
|
static String |
getRootName(File file)
Gets the root name of a file.
|
static boolean |
isIncluded(File file,
File directory)
Tests whether a file is contained in a directory.
|
static boolean |
isReadable(File file)
Tests whether the application can read from a file (or a folder).
|
static boolean |
isWritable(File file)
Tests whether the application can write to a file (or a folder).
|
static void |
move(File src,
File dest)
Move a file from one path to another.
|
public static File getCanonical(File file) throws IOException
file
- the file to testIOException
- If something goes wrongpublic static void move(File src, File dest) throws IOException
src
- The src pathdest
- The dest pathIOException
- If the move failspublic static void copy(File src, File dest, boolean overrideExisting) throws IOException
src
- The src pathdest
- The dest pathoverrideExisting
- true if copying to an existing file is ok.IOException
- If the copy failspublic static boolean deleteDirectory(File file)
file
- the directory to be deleted (if is is a file, the file will be deleted).public static boolean isIncluded(File file, File directory)
file
- The file to be testeddirectory
- The tested directorypublic static FileOutputStream getHiddenCompliantStream(File file) throws IOException
file
- The file to be opened for writingIOException
- If something goes wrongpublic static boolean isWritable(File file)
file
- The file or folder to testpublic static boolean isReadable(File file)
file
- The file or folder to testpublic static String getExtension(File file)
file
- The file.Copyright © 2022. All rights reserved.