Class FileUtils


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void copyDirectory​(java.io.File srcDir, java.io.File destDir)  
      static void copyFile​(java.io.File srcFile, java.io.File destFile, boolean preserveFileDate)
      Copied from the apache commons io project
      static void deleteDirectory​(java.io.File directory)
      Copied from the apache commons io project.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • deleteDirectory

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

        Deletes a directory recursively.

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

        public static void copyFile​(java.io.File srcFile,
                                    java.io.File destFile,
                                    boolean preserveFileDate)
                             throws java.io.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:
        java.io.IOException - if an error occurs
        java.io.IOException - if the output file length is not the same as the input file length after the copy completes
        java.lang.IllegalArgumentException - "Negative size" if the file is truncated so that the size is less than the position
      • copyDirectory

        public static void copyDirectory​(java.io.File srcDir,
                                         java.io.File destDir)
                                  throws java.io.IOException
        Throws:
        java.io.IOException