Class FileUtils

java.lang.Object
com.zfabrik.util.fs.FileUtils

public class FileUtils extends Object
Various file system utilities.
  • Field Details

  • Constructor Details

    • FileUtils

      public FileUtils()
  • Method Details

    • delete

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

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

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

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

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

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

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

      public static File computeSafePath(File base, 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: