|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.eu.miscedautils.CommonUtils.Paths
public class Paths
Collects filesystem paths using wildcards, preserving the directory structure. Copies, deletes, and zips paths.
Constructor Summary | |
---|---|
Paths()
Creates an empty Paths object. |
|
Paths(java.lang.String dir,
java.util.List<java.lang.String> patterns)
Creates a Paths object and calls glob(String, List) with the specified arguments. |
|
Paths(java.lang.String dir,
java.lang.String... patterns)
Creates a Paths object and calls glob(String, String[]) with the specified arguments. |
Method Summary | |
---|---|
void |
add(Paths paths)
Adds all paths from the specified Paths object to this Paths object. |
Paths |
add(java.lang.String dir,
java.lang.String name)
Adds a single path to this Paths object. |
Paths |
addFile(java.lang.String fullPath)
Adds a single path to this Paths object. |
Paths |
copyTo(java.lang.String destDir)
Copies the files and directories to the specified directory. |
int |
count()
|
boolean |
delete()
Deletes all the files, directories, and any files in the directories. |
Paths |
dirsOnly()
Returns a Paths object containing the paths that are directories. |
java.util.Iterator<java.io.File> |
fileIterator()
Iterates over the paths as File objects. |
Paths |
filesOnly()
Returns a Paths object containing the paths that are files. |
Paths |
flatten()
Returns a Paths object containing the paths that are files, as if each file were selected from its parent directory. |
java.util.List<java.io.File> |
getFiles()
Returns the paths as File objects. |
java.util.List<java.lang.String> |
getNames()
Returns the paths' filenames. |
java.util.List<java.lang.String> |
getPaths()
Returns the full paths. |
java.util.List<java.lang.String> |
getRelativePaths()
Returns the portion of the path after the root directory where the path was collected. |
Paths |
glob(java.lang.String dir,
java.util.List<java.lang.String> patterns)
Calls glob(String, String...) . |
Paths |
glob(java.lang.String dir,
java.lang.String... patterns)
Collects all files and directories in the specified directory matching the wildcard patterns. |
boolean |
isEmpty()
|
java.util.Iterator<java.lang.String> |
iterator()
Iterates over the absolute paths. |
static void |
main(java.lang.String[] args)
|
Paths |
regex(java.lang.String dir,
java.lang.String... patterns)
Collects all files and directories in the specified directory matching the regular expression patterns. |
static void |
setDefaultGlobExcludes(java.lang.String... defaultGlobExcludes)
Sets the exclude patterns that will be used in addition to the excludes specified for all glob searches. |
java.lang.String |
toString()
Returns the absolute paths delimited by commas. |
java.lang.String |
toString(java.lang.String delimiter)
Returns the absolute paths delimited by the specified character. |
void |
zip(java.lang.String destFile)
Compresses the files and directories specified by the paths into a new zip file at the specified location. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Paths()
public Paths(java.lang.String dir, java.lang.String... patterns)
glob(String, String[])
with the specified arguments.
public Paths(java.lang.String dir, java.util.List<java.lang.String> patterns)
glob(String, List)
with the specified arguments.
Method Detail |
---|
public Paths glob(java.lang.String dir, java.lang.String... patterns)
dir
- The directory containing the paths to collect. If it does not exist, no paths are collected. If null, "." is
assumed.patterns
- The wildcard patterns of the paths to collect or exclude. Patterns may optionally contain wildcards
represented by asterisks and question marks. If empty or omitted then the dir parameter is split on the "|"
character, the first element is used as the directory and remaining are used as the patterns. If null, ** is
assumed (collects all paths).public Paths glob(java.lang.String dir, java.util.List<java.lang.String> patterns)
glob(String, String...)
.
public Paths regex(java.lang.String dir, java.lang.String... patterns)
glob(String, String...)
because every file and directory under the specified directory must be
inspected.
dir
- The directory containing the paths to collect. If it does not exist, no paths are collected.patterns
- The regular expression patterns of the paths to collect or exclude. If empty or omitted then the dir
parameter is split on the "|" character, the first element is used as the directory and remaining are used as the
patterns. If null, ** is assumed (collects all paths).public Paths copyTo(java.lang.String destDir) throws java.io.IOException
java.io.IOException
public boolean delete()
public void zip(java.lang.String destFile) throws java.io.IOException
java.io.IOException
public int count()
public boolean isEmpty()
public java.lang.String toString(java.lang.String delimiter)
public java.lang.String toString()
toString
in class java.lang.Object
public Paths flatten()
public Paths filesOnly()
public Paths dirsOnly()
public java.util.List<java.io.File> getFiles()
public java.util.List<java.lang.String> getRelativePaths()
public java.util.List<java.lang.String> getPaths()
public java.util.List<java.lang.String> getNames()
public Paths addFile(java.lang.String fullPath)
public Paths add(java.lang.String dir, java.lang.String name)
public void add(Paths paths)
public java.util.Iterator<java.lang.String> iterator()
iterator
in interface java.lang.Iterable<java.lang.String>
public java.util.Iterator<java.io.File> fileIterator()
public static void setDefaultGlobExcludes(java.lang.String... defaultGlobExcludes)
public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |