java.lang.Object
io.sf.jclf.io.Dir
Wildcard-enabled directory utility.
Mainly useful as a WildcardFilter showcase.
Example of usage:
java -cp jclf.jar io.sf.jclf.io.Dir "/etc/h*"
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface used to process files that match a file filter. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Gets the basename of the path.static boolean
Copies a file.static boolean
Copies an origin file or directory to a destination path.static boolean
deleteRecursive
(File path) Recursively deletes a directory and all files and directories inside.static void
static int
wildcardFilter
(String wildcardPath, Dir.FilterListener listener) Given a path with wildcards (like/foo*\/*\/bar
), calls a listener for each matching path found in the local file structure.
-
Constructor Details
-
Dir
public Dir()
-
-
Method Details
-
main
-
baseName
Gets the basename of the path.If the path corresponds to a file, returns the path to parent directory, or null if there isn't, otherwise returns itself (as absolute path)
- Parameters:
path
- the path- Returns:
- the basename, or null if there isn't
-
wildcardFilter
Given a path with wildcards (like/foo*\/*\/bar
), calls a listener for each matching path found in the local file structure.- Parameters:
wildcardPath
- the path with wildcards.listener
- the listener.- Returns:
- the number of matching files found.
-
copyFile
Copies a file.- Parameters:
in
- the file to be copied.dest
- the destination path.force
- if true and the destination file exists, it will be removed.- Returns:
true
if the action was completed,false
otherwise.
-
deepCopy
Copies an origin file or directory to a destination path.If the origin id a directory, all files and directories inside it are copied as well.
- Parameters:
in
- the origin file.destDir
- destination path.- Returns:
true
if the action was completed,false
otherwise.
-
deleteRecursive
Recursively deletes a directory and all files and directories inside.- Parameters:
path
- the path to the directory.- Returns:
true
if the action was completed,false
otherwise.
-