Package io.deephaven.base
Class FileUtils
java.lang.Object
io.deephaven.base.FileUtils
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
cleanDirectory
(File path) Cleans the specified path.static URI
convertToURI
(File file, boolean isDirectory) Takes a file and convert it to a URI object with"file"
scheme.static URI
convertToURI
(String source, boolean isDirectory) Take the file source path or URI string and convert it to a URI object.static URI
convertToURI
(Path path, boolean isDirectory) Takes a path and convert it to a URI object with"file"
scheme.static void
deleteRecursively
(File file) static void
deleteRecursivelyOnNFS
(File file) Recursive delete method that copes with .nfs files.static void
deleteRecursivelyOnNFS
(File trashFile, File fileToBeDeleted) Recursive delete method that copes with .nfs files.static File[]
findAllFiles
(File dir) Scan directory recursively to find all filesstatic String[]
missingSafeListFilenames
(File directory) static String[]
missingSafeListFilenames
(File directory, FilenameFilter filter) static File[]
missingSafeListFiles
(File directory) static File[]
missingSafeListFiles
(File directory, FileFilter filter) static File[]
missingSafeListSubDirectories
(File directory) static String[]
missingSafeListSubDirectoryNames
(File directory) static void
moveRecursively
(File source, File destination, @Nullable FileFilter filter, boolean allowReplace) Move files accepted by a filter from their relative path under source to the same relative path under destination.static String
readTextFile
(File txtFile) static String
readTextFile
(InputStream txtFile)
-
Field Details
-
URI_SEPARATOR_CHAR
public static final char URI_SEPARATOR_CHAR- See Also:
-
URI_SEPARATOR
- See Also:
-
REPEATED_URI_SEPARATOR
- See Also:
-
REPEATED_URI_SEPARATOR_PATTERN
-
FILE_URI_SCHEME
- See Also:
-
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
cleanDirectory
Cleans the specified path. All files and subdirectories in the path will be deleted. (ie you'll be left with an empty directory).- Parameters:
path
- The path to clean
-
deleteRecursively
-
moveRecursively
public static void moveRecursively(File source, File destination, @Nullable @Nullable FileFilter filter, boolean allowReplace) Move files accepted by a filter from their relative path under source to the same relative path under destination. Creates missing destination subdirectories as needed.- Parameters:
source
- Must be a directory.destination
- Must be a directory if it exists.filter
- Applied to normal files, only. We recurse on directories automatically.allowReplace
- If the destination regular file exists, do we replace it, or silently ignore it?
-
deleteRecursivelyOnNFS
Recursive delete method that copes with .nfs files. Uses the file's parent as the trash directory.- Parameters:
file
-
-
deleteRecursivelyOnNFS
Recursive delete method that copes with .nfs files.- Parameters:
trashFile
- Filename to move regular files to before deletion. .nfs files may be created in its parent directory.fileToBeDeleted
- File or directory at which to begin recursive deletion.
-
findAllFiles
Scan directory recursively to find all files- Parameters:
dir
-- Returns:
-
missingSafeListFiles
-
missingSafeListFiles
-
missingSafeListSubDirectories
-
missingSafeListFilenames
-
missingSafeListFilenames
-
missingSafeListSubDirectoryNames
-
readTextFile
- Throws:
IOException
-
readTextFile
- Throws:
IOException
-
convertToURI
Take the file source path or URI string and convert it to a URI object. Any unnecessary path separators will be removed. The URI object will always beabsolute
, i.e., will always have a scheme.- Parameters:
source
- The file source path or URIisDirectory
- Whether the source is a directory- Returns:
- The URI object
-
convertToURI
Takes a file and convert it to a URI object with"file"
scheme. This method is preferred instead ofFile.toURI()
becauseFile.toURI()
internally callsFile.isDirectory()
, which typically invokes thestat
system call, resulting in filesystem metadata access.- Parameters:
file
- The fileisDirectory
- Whether the source file is a directory- Returns:
- The URI object
-
convertToURI
Takes a path and convert it to a URI object with"file"
scheme. This method is preferred instead ofPath.toUri()
becausePath.toUri()
internally invokes thestat
system call, resulting in filesystem metadata access.- Parameters:
path
- The pathisDirectory
- Whether the file is a directory- Returns:
- The URI object
-