Class FileUtils

java.lang.Object
panda.utilities.FileUtils

public final class FileUtils extends Object
  • Method Details

    • contains

      public static boolean contains(File[] files, String fileName)
      Check if a file is in the specified array
      Parameters:
      files - files
      fileName - name of file
      Returns:
      true if file is in specified array
    • getAmountOfFiles

      public static int getAmountOfFiles(File directory)
      Count files in the specified directory
      Parameters:
      directory - root directory
      Returns:
      amount of files
    • getContentOfFile

      public static String getContentOfFile(File file) throws IOException
      Returns:
      content of the specified file
      Throws:
      IOException
    • getContentAsLines

      public static String[] getContentAsLines(File file) throws IOException
      Returns:
      content of file divided by lines
      Throws:
      IOException
    • findFilesByExtension

      public static Collection<File> findFilesByExtension(String directory, String extension)
      Returns:
      collection of file with the specified extension
    • findFilesByExtension

      public static Collection<File> findFilesByExtension(File directory, String extension)
      Returns:
      collection of file with the specified extension
    • collectFiles

      public static Node<File> collectFiles(File directory)
      Collect all files (including files from subdirectories) from the given directory
      Parameters:
      directory - root
      Returns:
      tree node of collected files
    • overrideFile

      public static void overrideFile(File file, String content) throws IOException
      Override content of the specified file
      Throws:
      IOException
    • delete

      public static boolean delete(File file)
      Delete file or directory with content
      Parameters:
      file - file/directory
      Returns:
      true if succeeded
    • toFiles

      public static File[] toFiles(String... paths)
      Get vararg paths as array of File
      Parameters:
      paths - array of paths
      Returns:
      array of files
    • getName

      public static String getName(File file)
      Get file name without extension
      Returns:
      file name without extension
    • getName

      public static String getName(URL url)
      Get file name of URL
      Parameters:
      url - the url to check
      Returns:
      the name of file
    • getName

      public static String getName(String path)
      Get file name of path
      Parameters:
      path - the path to check
      Returns:
      the name of file