Class FileUtil


  • public class FileUtil
    extends Object
    Utility methods for operations on Files.
    • Constructor Detail

      • FileUtil

        public FileUtil()
    • Method Detail

      • getRelativePath

        @Deprecated
        public static String getRelativePath​(File subj,
                                             File relativeTo)
        Deprecated.
        Gets the relative representations of a file compared to another.
        Parameters:
        subj - The File to find the relative form for.
        relativeTo - The File 'subj' should be made relative to.
        Returns:
        The relative representation of subj.
      • getRelativeFile

        @Deprecated
        public static File getRelativeFile​(File subj,
                                           File relativeTo)
        Deprecated.
        Gets the relative representations of a file compared to another.
        Parameters:
        subj - The File to find the relative form for.
        relativeTo - The File 'subj' should be made relative to.
        Returns:
        The relative representation of subj.
      • getFileExtension

        @Deprecated
        public static String getFileExtension​(String fileName)
        Deprecated.
        Gets the extension of the specified file name.
        Parameters:
        fileName - A file name.
        Returns:
        The file name extension (e.g. "exe" or "txt"), or null if the file name does not have a (valid) extension.
      • isLegalFileName

        @Deprecated
        public static boolean isLegalFileName​(String fileName)
        Deprecated.
        Checks whether the specified file name is a legal (DOS/Windows-) file name.
        Parameters:
        fileName - name of the file
        Returns:
        true if all characters of the name are legal to use
      • isLegalFileNameChar

        @Deprecated
        public static boolean isLegalFileNameChar​(char c)
        Deprecated.
        Checks whether the specified character is a legal (DOS/Windows-) file name character.
        Parameters:
        c - character to check
        Returns:
        true if character is legal to use
      • copyFile

        @Deprecated
        public static void copyFile​(File source,
                                    File destination)
                             throws IOException
        Deprecated.
        Copies the contents of file source to file destination.
        Parameters:
        source - source file
        destination - destination file
        Throws:
        IOException
      • createDirIfNotExists

        @Deprecated
        public static void createDirIfNotExists​(File dir)
                                         throws IOException
        Deprecated.
        Creates a directory if it doesn't exist yet.
        Parameters:
        dir - The directory to create.
        Throws:
        IOException - If the creation of the directory failed.
      • deltree

        @Deprecated
        public static boolean deltree​(File directory)
        Deprecated.
        Deletes a directory, recursively deleting all the files and subdirectories in it, or just a file.
        Parameters:
        directory - file or directory to delete
        Returns:
        true if all files were deleted successfully.
      • deleteFiles

        @Deprecated
        public static boolean deleteFiles​(File directory)
        Deprecated.
        Deletes all files in the specified directory. Nothing happens when the specified File is not a directory.
        Parameters:
        directory -
        Returns:
        true when all files in the specified directory were successfully deleted, when there where no files or when the specified file was not a directory.
      • deleteChildren

        @Deprecated
        public static boolean deleteChildren​(File directory)
        Deprecated.
        Deletes all files and subdirectories in the specified directory. Nothing happens when the specified File is not a directory.
        Parameters:
        directory -
        Returns:
        true when all children were successfully deleted, when there were no children or when the file was not a directory.
      • moveRecursive

        @Deprecated
        public static boolean moveRecursive​(File from,
                                            File to,
                                            Collection<File> excludes)
        Deprecated.
        Moves the given file and all files under it (if it's a directory) to the given location, excluding the given collection of File objects!
        Parameters:
        from - File or directory to be moved
        to - The file or directory to rename to
        excludes - The File objects to be excluded; if a directory is excluded, all files under it are excluded as well!
        Returns:
        Whether moving was successful
      • deleteDir

        public static void deleteDir​(File dir)
                              throws IOException
        Deletes the specified directory and any files and directories in it recursively.
        Parameters:
        dir - The directory to remove.
        Throws:
        IOException - If the directory could not be removed.