Package org.pf4j.util

Class FileUtils

java.lang.Object
org.pf4j.util.FileUtils

public class FileUtils extends Object
  • Field Details

    • log

      private static final org.slf4j.Logger log
  • Constructor Details

    • FileUtils

      public FileUtils()
  • Method Details

    • readLines

      public static List<String> readLines(Path path, boolean ignoreComments) throws IOException
      Throws:
      IOException
    • writeLines

      @Deprecated public static void writeLines(Collection<String> lines, File file) throws IOException
      Deprecated.
      Throws:
      IOException
    • writeLines

      public static void writeLines(Collection<String> lines, Path path) throws IOException
      Throws:
      IOException
    • delete

      public static void delete(Path path) throws IOException
      Delete a file or recursively delete a folder, do not follow symlinks.
      Parameters:
      path - the file or folder to delete
      Throws:
      IOException - if something goes wrong
    • getJars

      public static List<File> getJars(Path folder)
    • getJars

      private static void getJars(List<File> bucket, Path folder)
    • findWithEnding

      public static Path findWithEnding(Path basePath, String... endings)
      Finds a path with various endings or null if not found.
      Parameters:
      basePath - the base name
      endings - a list of endings to search for
      Returns:
      new path or null if not found
    • optimisticDelete

      public static void optimisticDelete(Path path)
      Delete a file (not recursively) and ignore any errors.
      Parameters:
      path - the path to delete
    • expandIfZip

      public static Path expandIfZip(Path filePath) throws IOException
      Unzip a zip file in a directory that has the same name as the zip file. For example if the zip file is my-plugin.zip then the resulted directory is my-plugin.
      Parameters:
      filePath - the file to evaluate
      Returns:
      Path of unzipped folder or original path if this was not a zip file
      Throws:
      IOException - on error
    • isZipFile

      public static boolean isZipFile(Path path)
      Return true only if path is a zip file.
      Parameters:
      path - to a file/dir
      Returns:
      true if file with .zip ending
    • isJarFile

      public static boolean isJarFile(Path path)
      Return true only if path is a jar file.
      Parameters:
      path - to a file/dir
      Returns:
      true if file with .jar ending
    • getPath

      public static Path getPath(Path path, String first, String... more) throws IOException
      Throws:
      IOException
    • getPath

      public static Path getPath(URI uri, String first, String... more) throws IOException
      Throws:
      IOException
    • findFile

      public static Path findFile(Path directoryPath, String fileName)
    • getFileSystem

      private static FileSystem getFileSystem(URI uri) throws IOException
      Throws:
      IOException