Class FileUtils


  • public class FileUtils
    extends Object
    File utility class.
    Since:
    2.2.0
    Author:
    Lijun Liao (xipki)
    • Method Detail

      • deleteDirectory

        public static void deleteDirectory​(File directory)
                                    throws IOException
        Copied from the apache commons io project.

        Deletes a directory recursively.

        Parameters:
        directory - - directory to delete
        Throws:
        IOException - in case deletion is unsuccessful
        IllegalArgumentException - if directory does not exist or is not a directory
      • copyFile

        public static void copyFile​(File srcFile,
                                    File destFile,
                                    boolean preserveFileDate)
                             throws IOException
        Copied from the apache commons io project

        Internal copy file method. This caches the original file length, and an IOException will be thrown if the output file length is different from the current input file length. So it may fail if the file changes size. It may also fail with "IllegalArgumentException: Negative size" if the input file is truncated part way through copying the data and the new file size is less than the current position.

        Parameters:
        srcFile - - the validated source file, may not be null
        destFile - - the validated destination file, may not be null
        preserveFileDate - whether to preserve the file date
        Throws:
        IOException - if an error occurs
        IOException - if the output file length is not the same as the input file length after the copy completes
        IllegalArgumentException - "Negative size" if the file is truncated so that the size is less than the position