| Modifier and Type | Class and Description |
|---|---|
| public static interface | FileUtils.
input type A, output type B>Like a |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | EMPTY_DIRECTORIES_ONLY
Option to only delete empty directories. |
| public static final int | IGNORE_ERRORS
Option not to throw exceptions when a deletion finally doesn't succeed. |
| private static final Logger | |
| public static final int | NONE
Option to delete given |
| public static final int | RECURSIVE
Option to recursively delete given |
| public static final int | RETRY
Option to retry deletion if not successful |
| private static final Random | |
| public static final int | SKIP_MISSING
Option to skip deletion if file doesn't exist |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| public static boolean | Returns: true if the given file can be executed.a file)java. object.Whether the given file can be executed. |
| public static File | Returns: canonicalized file, or the unchanged input file if canonicalization failed or iffile == nullto be canonicalized; may be file)nullBest-effort variation of |
| public static void | createNewFile(File
the file to be created f)Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. |
| public static Path | Returns: the path to the symbolic linkthe path of the symbolic link to create path, String the target of the symbolic link target)Create a symbolic link |
| public static File | Returns: the temp dir created.prefix string prefix, String suffix string suffix, File The parent dir, can be null to use system default temp dir. dir)Create a temporary directory. |
| public static long | Returns: new amount of delay to wait before the next attempt.amount of delay waited before the last attempt. This is used
to seed the next delay interval. Should be 0 if there was no
prior delay. last, long shortest amount of allowable delay between attempts. min, long longest amount of allowable delay between attempts. max)Compute a delay in a |
| public static void | |
| public static void | |
| pack-priv static boolean | |
| pack-priv static BasicFileAttributes | Returns: BasicFileAttributes of the filethe file file)Return all the attributes of a file, without following symbolic links. |
| pack-priv static FS. | Returns: non null attributes objecta fs, File org. object.the file file)Get basic file attributes |
| public static FS. | Returns: file system attributes for the given file.a fs, File org. object.a file)java..Get file system attributes for the given file. |
| public static long | |
| private static void | |
| public static boolean | |
| pack-priv static boolean | Returns: true if the given file is a directory, not following
symbolic linksthe file file)Check if file is directory |
| pack-priv static boolean | |
| pack-priv static boolean | |
| public static boolean | Returns: a boolean true if the IOException is a stale NFS file handlean ioe)java. object.Determine if an IOException is a stale NFS file handle |
| public static boolean | Returns: a boolean true if the throwable or a cause in its causal chain is a stale NFS file handlea throwable)java. object.Determine if a throwable or a cause in its causal chain is a stale NFS file handle |
| pack-priv static boolean | |
| pack-priv static Instant | Returns: lastModified attribute for given file, not following symbolic linksfile path path)Get last modified timestamp of a file |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static File | Returns: on Mac: NFC normalizedjava., otherwise the passed
filea file)java..NFC normalize a file (on Mac), otherwise do nothing |
| public static String | Returns: on Mac: NFC normalized form of given namea name)java. object.On Mac: get NFC normalized form of given name, otherwise the given name. |
| public static String | Returns: file's path as a Stringa file)java..Convert a path to String, replacing separators as necessary. |
| public static String | Returns: target path of the symlink, or null if it is not a symbolic linka path)java. object.Read target path of the symlink. |
| public static < result type T> T | Returns: the result of thereader, or null if the file
does not existto read file, FileUtils.for reading the file and creating an instance of readerTInvokes the given |
| public static String | Returns: Relative path frombase to otherBase path base, String Destination path other)Expresses |
| public static String | Returns: Relative path frombase to otherBase path base, String Destination path other)Expresses |
| public static String | Returns: A relative path that, when resolved againstbase,
will yield the original other.The path against which base, String other should be
relativized. This will be assumed to denote the path to a
folder and not a file.The path that will be made relative to other, String base.A string that separates components of the path. In practice, this is "/" or "\\". dirSeparator, boolean Whether to consider differently-cased directory names as distinct caseSensitive)Expresses For example, if called with the two following paths :
|
| public static void | |
| public static void | rename(final File
the old file src, final File the new file dst, CopyOption... options)Rename a file or folder using the passed
|
| public static void | |
| pack-priv static void | setLastModified(Path
file path path, Instant last modified timestamp of the file time)Set the last modified time of a file system object. |
| public static Path | Returns: the path represented by the fileFile to be converted to PathSafe conversion from |
| public static void |
| EMPTY_DIRECTORIES_ONLY | back to summary |
|---|---|
| public static final int EMPTY_DIRECTORIES_ONLY Option to only delete empty directories. This option can be combined with
| |
| IGNORE_ERRORS | back to summary |
|---|---|
| public static final int IGNORE_ERRORS Option not to throw exceptions when a deletion finally doesn't succeed.
| |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| NONE | back to summary |
|---|---|
| public static final int NONE Option to delete given | |
| RECURSIVE | back to summary |
|---|---|
| public static final int RECURSIVE Option to recursively delete given | |
| RETRY | back to summary |
|---|---|
| public static final int RETRY Option to retry deletion if not successful | |
| RNG | back to summary |
|---|---|
| private static final Random RNG | |
| SKIP_MISSING | back to summary |
|---|---|
| public static final int SKIP_MISSING Option to skip deletion if file doesn't exist | |
| FileUtils | back to summary |
|---|---|
| public FileUtils() | |
| backOff | back to summary |
|---|---|
| private static void backOff(long delay, IOException cause) throws IOException | |
| canExecute | back to summary |
|---|---|
| public static boolean canExecute(File file) Whether the given file can be executed.
| |
| canonicalize | back to summary |
|---|---|
| public static File canonicalize(File file) Best-effort variation of
| |
| createNewFile | back to summary |
|---|---|
| public static void createNewFile(File f) throws IOException Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. The check for the existence of the file and the creation of the file if it does not exist are a single operation that is atomic with respect to all other filesystem activities that might affect the file. Note this method should not be used for file-locking, as the resulting
protocol cannot be made to work reliably. The
| |
| createSymLink | back to summary |
|---|---|
| public static Path createSymLink(File path, String target) throws IOException Create a symbolic link
| |
| createTempDir | back to summary |
|---|---|
| public static File createTempDir(String prefix, String suffix, File dir) throws IOException Create a temporary directory.
| |
| delay | back to summary |
|---|---|
| public static long delay(long last, long min, long max) Compute a delay in a
| |
| delete | back to summary |
|---|---|
| public static void delete(File f) throws IOException Delete file or empty folder
| |
| delete | back to summary |
|---|---|
| public static void delete(File f, int options) throws IOException Delete file or folder
| |
| exists | back to summary |
|---|---|
| pack-priv static boolean exists(File file) Whether the file exists
| |
| fileAttributes | back to summary |
|---|---|
| pack-priv static BasicFileAttributes fileAttributes(File file) throws IOException Return all the attributes of a file, without following symbolic links.
| |
| getFileAttributesBasic | back to summary |
|---|---|
| pack-priv static FS. Get basic file attributes
| |
| getFileAttributesPosix | back to summary |
|---|---|
| public static FS. Get file system attributes for the given file.
| |
| getLength | back to summary |
|---|---|
| public static long getLength(File file) throws IOException Get file length
| |
| handleDeleteException | back to summary |
|---|---|
| private static void handleDeleteException(File f, IOException e, int allOptions, int checkOptions) throws IOException | |
| hasFiles | back to summary |
|---|---|
| public static boolean hasFiles(Path dir) throws IOException Whether the path is a directory with files in it.
| |
| isDirectory | back to summary |
|---|---|
| pack-priv static boolean isDirectory(File file) Check if file is directory
| |
| isFile | back to summary |
|---|---|
| pack-priv static boolean isFile(File file) Check if File is a file
| |
| isHidden | back to summary |
|---|---|
| pack-priv static boolean isHidden(File file) throws IOException Check if file is hidden (on Windows)
| |
| isStaleFileHandle | back to summary |
|---|---|
| public static boolean isStaleFileHandle(IOException ioe) Determine if an IOException is a stale NFS file handle
| |
| isStaleFileHandleInCausalChain | back to summary |
|---|---|
| public static boolean isStaleFileHandleInCausalChain(Throwable throwable) Determine if a throwable or a cause in its causal chain is a stale NFS file handle
| |
| isSymlink | back to summary |
|---|---|
| pack-priv static boolean isSymlink(File file) Check if file is a symlink
| |
| lastModifiedInstant | back to summary |
|---|---|
| pack-priv static Instant lastModifiedInstant(Path path) Get last modified timestamp of a file | |
| mkdir | back to summary |
|---|---|
| public static void mkdir(File d) throws IOException Creates the directory named by this abstract pathname.
| |
| mkdir | back to summary |
|---|---|
| public static void mkdir(File d, boolean skipExisting) throws IOException Creates the directory named by this abstract pathname.
| |
| mkdirs | back to summary |
|---|---|
| public static void mkdirs(File d) throws IOException Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.
| |
| mkdirs | back to summary |
|---|---|
| public static void mkdirs(File d, boolean skipExisting) throws IOException Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.
| |
| normalize | back to summary |
|---|---|
| public static File normalize(File file) NFC normalize a file (on Mac), otherwise do nothing
| |
| normalize | back to summary |
|---|---|
| public static String normalize(String name) On Mac: get NFC normalized form of given name, otherwise the given name.
| |
| pathToString | back to summary |
|---|---|
| public static String pathToString(File file) Convert a path to String, replacing separators as necessary.
| |
| readSymLink | back to summary |
|---|---|
| public static String readSymLink(File path) throws IOException Read target path of the symlink.
| |
| readWithRetries | back to summary |
|---|---|
| public static <T> T readWithRetries(File file, FileUtils. Invokes the given
| |
| relativizeGitPath | back to summary |
|---|---|
| public static String relativizeGitPath(String base, String other) Expresses | |
| relativizeNativePath | back to summary |
|---|---|
| public static String relativizeNativePath(String base, String other) Expresses | |
| relativizePath | back to summary |
|---|---|
| public static String relativizePath(String base, String other, String dirSeparator, boolean caseSensitive) Expresses For example, if called with the two following paths : This will return "..\\another_project\\pom.xml". Note that this will return the empty String if
| |
| rename | back to summary |
|---|---|
| public static void rename(File src, File dst) throws IOException Rename a file or folder. If the rename fails and if we are running on a filesystem where it makes sense to repeat a failing rename then repeat the rename operation up to 9 times with 100ms sleep time between two calls. Furthermore if the destination exists and is directory hierarchy with only directories in it, the whole directory hierarchy will be deleted. If the target represents a non-empty directory structure, empty subdirectories within that structure may or may not be deleted even if the method fails. Furthermore if the destination exists and is a file then the file will be deleted and then the rename is retried. This operation is not atomic.
| |
| rename | back to summary |
|---|---|
| public static void rename(final File src, final File dst, CopyOption... options) throws AtomicMoveNotSupportedException, IOException Rename a file or folder using the passed
| |
| setHidden | back to summary |
|---|---|
| public static void setHidden(File file, boolean hidden) throws IOException Set a file hidden (on Windows)
| |
| setLastModified | back to summary |
|---|---|
| pack-priv static void setLastModified(Path path, Instant time) throws IOException Set the last modified time of a file system object.
| |
| toPath | back to summary |
|---|---|
| public static Path toPath(File f) throws IOException Safe conversion from
| |
| touch | back to summary |
|---|---|
| public static void touch(Path f) throws IOException Touch the given file
| |
java.util.function.Function but throwing an
Exception.
| Modifier and Type | Method and Description |
|---|---|
| public B |
| apply | back to summary |
|---|---|
| public B apply(A t) throws Exception Performs the function.
| |