Package com.zfabrik.util.fs
Class FileUtils
java.lang.Object
com.zfabrik.util.fs.FileUtils
Various file system utilities.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic File
computeSafePath
(File base, String pathName) Compute a good file system location for a possibly path style name relative to some base folder.static void
copy
(File from, File to, FileFilter filter) copy files or foldersstatic void
delete file or folder recursivelystatic void
unzip a file to a folderstatic void
zip a folder to a filestatic void
zip
(File src, File target, FileFilter filter) zip a folder to a filestatic void
zip a folder to a filestatic void
zip
(File src, String path, File target, FileFilter filter) zip a file or folder to a file
-
Field Details
-
ALL_FILES
-
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
delete
delete file or folder recursively- Parameters:
g
-
-
copy
copy files or folders- Parameters:
from
-to
-filter
-- Throws:
Exception
-
zip
zip a folder to a file- Throws:
IOException
-
zip
zip a folder to a file- Throws:
IOException
-
zip
zip a folder to a file- Throws:
IOException
-
zip
zip a file or folder to a file- Throws:
IOException
-
unzip
unzip a file to a folder- Parameters:
src
-target
-- Throws:
IOException
-
computeSafePath
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 tocomputeSafePath(new File(base,"a"),"b")
- Parameters:
base
-pathName
-- Returns:
-