public final class FileUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static void |
copyDirectory(@NonNull java.io.File srcDir,
@NonNull java.io.File destDir,
java.nio.file.CopyOption... options)
Copies a directory recursively, preserving the files last modified date.
|
static void |
copyFile(@NonNull java.io.File srcFile,
@NonNull java.io.File destFile,
java.nio.file.CopyOption... options)
Copies a file to another path, preserving the last modified date.
|
static void |
copyFileToDirectory(@NonNull java.io.File srcFile,
@NonNull java.io.File destDir,
java.nio.file.CopyOption... options)
Copies a file to a directory, preserving the last modified date.
|
static boolean |
delete(@Nullable java.io.File file)
Deletes a file.
|
static boolean |
deleteQuietly(@Nullable java.io.File file)
Deletes a file, never throwing an exception.
|
static @Nullable java.lang.String |
getBaseName(@Nullable java.lang.String filename)
Gets the name minus the path and extension from a full filename.
|
static @Nullable java.lang.String |
getExtension(@Nullable java.lang.String filename)
Gets the file extension from a full filename.
|
static @Nullable java.lang.String |
getName(@Nullable java.lang.String filename)
Gets the name minus the path from a full filename.
|
static @NonNull java.lang.String |
readFileToString(@NonNull java.io.File file,
@NonNull java.nio.charset.Charset encoding)
Reads the contents of a file into a String.
|
public static void copyFile(@NonNull java.io.File srcFile,
@NonNull java.io.File destFile,
java.nio.file.CopyOption... options)
throws java.io.IOException
srcFile - An existing file to copy, must not be null.destFile - The target file, must not be null.options - Options specifying how the copy should be done.java.io.IOException - If an IO error occurs.public static void copyFileToDirectory(@NonNull java.io.File srcFile,
@NonNull java.io.File destDir,
java.nio.file.CopyOption... options)
throws java.io.IOException
srcFile - An existing file to copy, must not be null.destDir - The directory to place the copy in, must not be null.options - Options specifying how the copy should be done.java.io.IOException - If an IO error occurs.public static void copyDirectory(@NonNull java.io.File srcDir,
@NonNull java.io.File destDir,
java.nio.file.CopyOption... options)
throws java.io.IOException
srcDir - An existing directory to copy, must not be null.destDir - The target directory, must not be null.options - Options specifying how the copy should be done.java.io.IOException - If an IO error occurs.public static boolean delete(@Nullable java.io.File file)
throws java.io.IOException
file - File or directory to delete, can be null.true If the file or directory was deleted, false otherwise. The file or
directory is considered deleted if it exists entering the function and if it does not exist
when the function ends, meaning that a null input file or a file that does not
exist will return false.java.io.IOException - If an IO error occurs.public static boolean deleteQuietly(@Nullable java.io.File file)
file - File or directory to delete, can be null.true If the file or directory is deleted, false otherwise.public static @Nullable java.lang.String getBaseName(@Nullable java.lang.String filename)
filename - The filename to query, may be null.public static @Nullable java.lang.String getExtension(@Nullable java.lang.String filename)
filename - The filename to query, may be null.public static @Nullable java.lang.String getName(@Nullable java.lang.String filename)
filename - The filename to query, may be null.public static @NonNull java.lang.String readFileToString(@NonNull java.io.File file,
@NonNull java.nio.charset.Charset encoding)
throws java.io.IOException
file - The file to read, must not be null.encoding - The encoding to use, must not be null.null.java.io.IOException - If an IO error occurs.Copyright © 2022 - present; JODConverter. All rights reserved.