public final class MostFiles extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
MostFiles.DeleteRecursivelyOptions |
| Modifier and Type | Field and Description |
|---|---|
static long |
S_IFDIR |
static long |
S_IFLNK |
static long |
S_IFREG |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
concatenateFiles(Path dest,
Iterable<Path> pathsToConcatenate)
Concatenates the contents of one or more files.
|
static void |
copyRecursively(Path fromPath,
Path toPath)
Recursively copies all files under
fromPath to toPath. |
static void |
copyRecursively(Path fromPath,
Path toPath,
java.util.function.Function<Path,Path> transform)
Recursively copies all files under
fromPath to toPath. |
static void |
copyRecursively(Path fromPath,
Path toPath,
java.util.function.Function<Path,Path> transform,
java.util.function.Function<Path,Boolean> filter) |
static void |
deleteRecursively(Path path) |
static void |
deleteRecursivelyIfExists(Path path) |
static void |
deleteRecursivelyWithOptions(Path path,
EnumSet<MostFiles.DeleteRecursivelyOptions> options) |
static void |
makeExecutable(Path file)
Tries to make the specified file executable.
|
static String |
sanitize(String name)
Given a file name, replace any illegal characters from it.
|
static void |
sortFilesByAccessTime(File[] files)
Does an in-place sort of the specified
files array. |
static void |
writeLinesToFile(Iterable<String> lines,
AbsPath file)
Writes the specified lines to the specified file, encoded as UTF-8.
|
static void |
writeLinesToFile(Iterable<String> lines,
Path file)
Writes the specified lines to the specified file, encoded as UTF-8.
|
public static final long S_IFDIR
public static final long S_IFREG
public static final long S_IFLNK
public static void deleteRecursivelyIfExists(Path path) throws IOException
IOExceptionpublic static void copyRecursively(Path fromPath, Path toPath) throws IOException
fromPath to toPath.IOExceptionpublic static void copyRecursively(Path fromPath, Path toPath, java.util.function.Function<Path,Path> transform) throws IOException
fromPath to toPath. The transform
will be applied after the destination path for a file has been relativized. This will remove
any existing files in the toPath if there is a conflict.fromPath - item to copytoPath - destination of copytransform - renaming function to apply when copying. If this function returns null, then
the file is not copied.IOExceptionpublic static void copyRecursively(Path fromPath, Path toPath, java.util.function.Function<Path,Path> transform, java.util.function.Function<Path,Boolean> filter) throws IOException
IOExceptionpublic static void deleteRecursively(Path path) throws IOException
IOExceptionpublic static void deleteRecursivelyWithOptions(Path path, EnumSet<MostFiles.DeleteRecursivelyOptions> options) throws IOException
IOExceptionpublic static void writeLinesToFile(Iterable<String> lines, Path file) throws IOException
IOExceptionpublic static void writeLinesToFile(Iterable<String> lines, AbsPath file) throws IOException
IOExceptionpublic static void sortFilesByAccessTime(File[] files)
files array. Most recently accessed files will
be at the front of the array when sorted.public static void makeExecutable(Path file) throws IOException
If the file system does not support the executable permission or the operation fails, a
java.io.IOException is thrown.
IOExceptionpublic static String sanitize(String name)
name - The file name to sanitizepublic static boolean concatenateFiles(Path dest, Iterable<Path> pathsToConcatenate) throws IOException
dest - The path to which the concatenated files' contents are written.pathsToConcatenate - The paths whose contents are concatenated to dest.true if any data was concatenated to dest, false otherwise.IOException