Class FileUtils


  • public class FileUtils
    extends java.lang.Object
    Various file system utilities.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.io.FileFilter ALL_FILES  
    • Constructor Summary

      Constructors 
      Constructor Description
      FileUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.io.File computeSafePath​(java.io.File base, java.lang.String pathName)
      Compute a good file system location for a possibly path style name relative to some base folder.
      static void copy​(java.io.File from, java.io.File to, java.io.FileFilter filter)
      copy files or folders
      static void delete​(java.io.File g)
      delete file or folder recursively
      static void unzip​(java.io.File src, java.io.File target)
      unzip a file to a folder
      static void zip​(java.io.File src, java.io.File target)
      zip a folder to a file
      static void zip​(java.io.File src, java.io.File target, java.io.FileFilter filter)
      zip a folder to a file
      static void zip​(java.io.File src, java.lang.String path, java.io.File target)
      zip a folder to a file
      static void zip​(java.io.File src, java.lang.String path, java.io.File target, java.io.FileFilter filter)
      zip a file or folder to a file
      • Methods inherited from class java.lang.Object

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

      • ALL_FILES

        public static java.io.FileFilter ALL_FILES
    • Constructor Detail

      • FileUtils

        public FileUtils()
    • Method Detail

      • delete

        public static void delete​(java.io.File g)
        delete file or folder recursively
        Parameters:
        g -
      • copy

        public static void copy​(java.io.File from,
                                java.io.File to,
                                java.io.FileFilter filter)
                         throws java.lang.Exception
        copy files or folders
        Parameters:
        from -
        to -
        filter -
        Throws:
        java.lang.Exception
      • zip

        public static void zip​(java.io.File src,
                               java.io.File target)
                        throws java.io.IOException
        zip a folder to a file
        Throws:
        java.io.IOException
      • zip

        public static void zip​(java.io.File src,
                               java.io.File target,
                               java.io.FileFilter filter)
                        throws java.io.IOException
        zip a folder to a file
        Throws:
        java.io.IOException
      • zip

        public static void zip​(java.io.File src,
                               java.lang.String path,
                               java.io.File target)
                        throws java.io.IOException
        zip a folder to a file
        Throws:
        java.io.IOException
      • zip

        public static void zip​(java.io.File src,
                               java.lang.String path,
                               java.io.File target,
                               java.io.FileFilter filter)
                        throws java.io.IOException
        zip a file or folder to a file
        Throws:
        java.io.IOException
      • unzip

        public static void unzip​(java.io.File src,
                                 java.io.File target)
                          throws java.io.IOException
        unzip a file to a folder
        Parameters:
        src -
        target -
        Throws:
        java.io.IOException
      • computeSafePath

        public static java.io.File computeSafePath​(java.io.File base,
                                                   java.lang.String pathName)
        Compute a good file system location for a possibly path style name relative to some base folder. That is: Slashes will be kept in the path name but characters in path segments will be replaced if considered problematic. Furthermore, the first path segment will be augmented by a hash representation of the initial path name to ensure uniqueness. This method is not transitive, i.e.
         computeSafePath(base,"a/b")
         
        is not equal to
         computeSafePath(new File(base,"a"),"b")
         
        Parameters:
        base -
        pathName -
        Returns: