Package io.deephaven.base
Class FileUtils
java.lang.Object
io.deephaven.base.FileUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcleanDirectory(File path) Cleans the specified path.static URIconvertToURI(File file, boolean isDirectory) Takes a file and convert it to a URI object with"file"scheme.static URIconvertToURI(String source, boolean isDirectory) Take the file source path or URI string and convert it to a URI object.static URIconvertToURI(Path path, boolean isDirectory) Takes a path and convert it to a URI object with"file"scheme.static voiddeleteRecursively(File file) static voiddeleteRecursivelyOnNFS(File file) Recursive delete method that copes with .nfs files.static voiddeleteRecursivelyOnNFS(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 voidmoveRecursively(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 StringreadTextFile(File txtFile) static StringreadTextFile(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- File or directory at which to begin recursive deletion.
-
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. Anysourcethat is parsable viaURI(String)with the scheme "file" must also be a validfile via URI. Asourcethat results in aURISyntaxExceptionwill be assumed to be afile via pathname, unless thesourceappears to 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 thestatsystem 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 thestatsystem call, resulting in filesystem metadata access.- Parameters:
path- The pathisDirectory- Whether the file is a directory- Returns:
- The URI object
-