Class FileUtil

java.lang.Object
de.muehlencord.shared.util.file.FileUtil

public abstract class FileUtil extends Object
Author:
Joern Muehlencord (joern@muehlencord.de)
  • Constructor Details

    • FileUtil

      public FileUtil()
  • Method Details

    • getFilesFromDirecotry

      public static List<File> getFilesFromDirecotry(String directory, String regEx) throws FileHandlingException
      returns a list of files found by the given regexp in the given folder
      Parameters:
      directory - the folder to search in as a string
      regEx - the regular expression to search with
      Returns:
      a list of files
      Throws:
      FileHandlingException - if the given directory cannot be found
    • getFileName

      public static File getFileName(String outputFolder, Format ft, int number)
      returns a file handle to a file in the given folder using the given formater and the given number.
      Parameters:
      outputFolder - the folder to link the file to as strnig
      ft - a format object to use to format the filename of the given file
      number - a number used to call the given formater to name the file number
      Returns:
      a file handle build from formater and number linked to given directory
    • copyFileTo

      @Deprecated public static boolean copyFileTo(File source, File destination)
      Deprecated.
      use Files.copy instead
      copies the given source file to the given destination filename
      Parameters:
      source - the file to copy from
      destination - the destination filename to copy the source file to
      Returns:
      true, if the vile was copied, false, else
    • moveFileTo

      public static boolean moveFileTo(File source, File destination)
      moves / renames the given file to the new file
      Parameters:
      source - the source file
      destination - the file to rename the source file to
      Returns:
      true, if move / rename was successfull; false else
    • doesPathExists

      public static boolean doesPathExists(String path)
      returns true, if the givn path exists; false otherwise
      Parameters:
      path - the path to check
      Returns:
      true, if the givn path exists; false otherwise
    • md5Sum

      public static String md5Sum(String fileName) throws IOException
      Throws:
      IOException
    • readFile

      public static String readFile(String inputFile, String encoding) throws IOException
      Reads the content of the given file and returns it as String
      Parameters:
      inputFile - the input file to read
      encoding - the encoding of the file to load
      Returns:
      the content of the file as string
      Throws:
      IOException - if the file cannot be read