public final class FileUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static Node<File> |
collectFiles(File directory)
Collect all files (including files from subdirectories) from the given directory
|
static List<Path> |
collectPaths(Path root,
int estimatedAmountOfPaths,
Predicate<Path> pathFilter)
Efficient way to collect all paths (with subdirectories) in the specified directory
|
static List<Path> |
collectPaths(Path root,
Predicate<Path> pathFilter)
Efficient way to collect all paths (with subdirectories) in the specified directory
|
static boolean |
contains(File[] files,
String fileName)
Check if a file is in the specified array
|
static boolean |
delete(File file)
Delete file or directory with content
|
static Collection<File> |
findFilesByExtension(File directory,
String extension) |
static Collection<File> |
findFilesByExtension(String directory,
String extension) |
static int |
getAmountOfFiles(File directory)
Count files in the specified directory
|
static String[] |
getContentAsLines(File file) |
static String |
getContentOfFile(File file) |
static String |
getName(File file)
Get file name without extension
|
static String |
getName(String path)
Get file name of path
|
static String |
getName(URL url)
Get file name of URL
|
static void |
overrideFile(File file,
String content)
Override content of the specified file
|
static File[] |
toFiles(String... paths)
Get vararg paths as array of
File |
public static List<Path> collectPaths(Path root, Predicate<Path> pathFilter)
root - the directory to search inpathFilter - if path matches the filter, path is added to the list. Otherwise path will be checked as directory.public static List<Path> collectPaths(Path root, int estimatedAmountOfPaths, Predicate<Path> pathFilter)
root - the directory to search inestimatedAmountOfPaths - the estimated amount of paths to collectpathFilter - if path matches the filter, path is added to the list. Otherwise path will be checked as directory.public static boolean contains(File[] files, String fileName)
files - filesfileName - name of filepublic static int getAmountOfFiles(File directory)
directory - root directorypublic static String getContentOfFile(File file) throws IOException
IOExceptionpublic static String[] getContentAsLines(File file) throws IOException
IOExceptionpublic static Collection<File> findFilesByExtension(String directory, String extension)
public static Collection<File> findFilesByExtension(File directory, String extension)
public static Node<File> collectFiles(File directory)
directory - rootpublic static void overrideFile(File file, String content) throws IOException
IOExceptionpublic static boolean delete(File file)
file - file/directorypublic static File[] toFiles(String... paths)
Filepaths - array of pathspublic static String getName(File file)
public static String getName(URL url)
url - the url to checkCopyright © 2020. All rights reserved.