Class FileUtils

java.lang.Object
io.deephaven.base.FileUtils

public class FileUtils extends Object
  • Field Details

  • Constructor Details

    • FileUtils

      public FileUtils()
  • Method Details

    • cleanDirectory

      public static void cleanDirectory(File path)
      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

      public static void deleteRecursively(File file)
    • 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

      public static void deleteRecursivelyOnNFS(File file)
      Recursive delete method that copes with .nfs files. Uses the file's parent as the trash directory.
      Parameters:
      file -
    • deleteRecursivelyOnNFS

      public static void deleteRecursivelyOnNFS(File trashFile, File fileToBeDeleted)
      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

      public static File[] findAllFiles(File dir)
      Scan directory recursively to find all files
      Parameters:
      dir -
      Returns:
    • missingSafeListFiles

      public static File[] missingSafeListFiles(File directory)
    • missingSafeListFiles

      public static File[] missingSafeListFiles(File directory, FileFilter filter)
    • missingSafeListSubDirectories

      public static File[] missingSafeListSubDirectories(File directory)
    • missingSafeListFilenames

      public static String[] missingSafeListFilenames(File directory)
    • missingSafeListFilenames

      public static String[] missingSafeListFilenames(File directory, FilenameFilter filter)
    • missingSafeListSubDirectoryNames

      public static String[] missingSafeListSubDirectoryNames(File directory)
    • readTextFile

      public static String readTextFile(File txtFile) throws IOException
      Throws:
      IOException
    • readTextFile

      public static String readTextFile(InputStream txtFile) throws IOException
      Throws:
      IOException
    • convertToURI

      public static URI convertToURI(String source, boolean isDirectory)
      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 be absolute, i.e., will always have a scheme.
      Parameters:
      source - The file source path or URI
      isDirectory - Whether the source is a directory
      Returns:
      The URI object
    • convertToURI

      public static URI convertToURI(File file, boolean isDirectory)
      Takes a file and convert it to a URI object with "file" scheme. This method is preferred instead of File.toURI() because File.toURI() internally calls File.isDirectory(), which typically invokes the stat system call, resulting in filesystem metadata access.
      Parameters:
      file - The file
      isDirectory - Whether the source file is a directory
      Returns:
      The URI object
    • convertToURI

      public static URI convertToURI(Path path, boolean isDirectory)
      Takes a path and convert it to a URI object with "file" scheme. This method is preferred instead of Path.toUri() because Path.toUri() internally invokes the stat system call, resulting in filesystem metadata access.
      Parameters:
      path - The path
      isDirectory - Whether the file is a directory
      Returns:
      The URI object