Package play.libs

Class Files

java.lang.Object
play.libs.Files

public class Files extends Object
Files utils
  • Field Details

    • ILLEGAL_FILENAME_CHARS

      public static final char[] ILLEGAL_FILENAME_CHARS
      Characters that are invalid in Windows OS file names (Unix only forbids '/' character)
    • ILLEGAL_FILENAME_CHARS_REPLACE

      public static final char ILLEGAL_FILENAME_CHARS_REPLACE
      See Also:
  • Constructor Details

    • Files

      public Files()
  • Method Details

    • isSameFile

      public static boolean isSameFile(File a, File b)
      Indicate if two file refers to the same one
      Parameters:
      a - First file to compare
      b - Second file to compare
      Returns:
      true is file are the same
    • copy

      public static void copy(File from, File to)
      Just copy a file
      Parameters:
      from - source of the file
      to - destination file
    • delete

      public static boolean delete(File file)
      Just delete a file. If the file is a directory, it's work.
      Parameters:
      file - The file to delete
      Returns:
      true if and only if the file is successfully deleted; false otherwise
    • deleteDirectory

      public static boolean deleteDirectory(File path)
      Recursively delete a directory.
      Parameters:
      path - Path of the directory
      Returns:
      true if and only if the directory is successfully deleted; false otherwise
    • copyDir

      public static boolean copyDir(File from, File to)
    • unzip

      public static void unzip(File from, File to)
    • zip

      public static void zip(File directory, File zipFile)
    • sanitizeFileName

      public static String sanitizeFileName(String fileName)
      Replace all characters that are invalid in file names on Windows or Unix operating systems with ILLEGAL_FILENAME_CHARS_REPLACE character.

      This method makes sure your file name can successfully be used to write new file to disk. Invalid characters are listed in ILLEGAL_FILENAME_CHARS array.

      Parameters:
      fileName - File name to sanitize
      Returns:
      Sanitized file name (new String object) if found invalid characters or same string if not
    • sanitizeFileName

      public static String sanitizeFileName(String fileName, char replacement)
      Replace all characters that are invalid in file names on Windows or Unix operating systems with passed in character.

      This method makes sure your file name can successfully be used to write new file to disk. Invalid characters are listed in ILLEGAL_FILENAME_CHARS array.

      Parameters:
      fileName - File name to sanitize
      replacement - character to use as replacement for invalid chars
      Returns:
      Sanitized file name (new String object) if found invalid characters or same string if not