|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.metasyntactic.io.FileUtilities
Contains useful static methods for manipulating files and directory structures.
| Field Summary | |
static int |
IGNORE_CASE
|
static int |
REVERSE_SORT
|
static int |
SORT_BY_DATE
Flag to tell the comparator to sort files by their last modifed date |
static int |
SORT_BY_EXTENSION
Flag to tell the comparator to sort files by their extensions. |
static int |
SORT_BY_NAME
Flag to tell the comparator to sort files by their name |
static int |
SORT_BY_SIZE
Flag to tell the comparator to sort files by their size |
| Constructor Summary | |
FileUtilities()
|
|
| Method Summary | |
static void |
copy(java.io.File from,
java.io.File to)
|
static java.util.Comparator |
fileComparator()
Returns a comparator that will compare files only by name, (not including its path). |
static java.util.Comparator |
fileComparator(int criteria)
Returns a Comparator that can be used (for example) as the comparator passed to java.util.Arrays.sort(Object[], Comparator). |
static void |
growFile(java.io.File file,
byte[] content,
long position)
Grows file by inserting the byte array into the file at the location specified |
static void |
growFile(java.io.File file,
int length,
byte val,
long position)
Grows file by inserting 'length' bytes of value 'val' into the file at the position specified |
static void |
growFile(java.io.File file,
int length,
long position)
Grows file by inserting 'length' zero'ed bytes at the position specified |
static void |
main(java.lang.String[] args)
|
static void |
recurse(java.io.File directory,
boolean applyOperatorToDirectories,
Operator operator)
Recurses all the files and directories reachable from this directory and operates on them in the manner implemented in the Operator.operate method. |
static void |
simpleRecurse(java.io.File directory,
boolean applyOperatorToDirectories,
Operator operator)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int SORT_BY_EXTENSION
public static final int SORT_BY_NAME
public static final int SORT_BY_SIZE
public static final int SORT_BY_DATE
public static final int IGNORE_CASE
public static final int REVERSE_SORT
| Constructor Detail |
public FileUtilities()
| Method Detail |
public static java.util.Comparator fileComparator()
public static java.util.Comparator fileComparator(int criteria)
Criteria includes:
REVERSE_SORT, directories will
appear before files. However, the list of directories, and the list of
files will both appear in the reverse order of normal. To indicate that
you want the files sorted in reverse order, 'bitwise or'
( | ) REVERSE_SORT with the sorting option you want. If an
invalied sorting code is passed to this method, it will default to
sorting by name.
Examples:
criteria - The type of sort. | this value with
REVERSE_SORT to get the reverse effect on the list of
directories and files.
public static void recurse(java.io.File directory,
boolean applyOperatorToDirectories,
Operator operator)
Two important things to note. First: this method is thread safe. You can call it from one thread on one directory, and another thread on another directory and will get the proper results. Second: this method is intelligent when it comes to directory structure. It will not recurse directories it has already seen.
directory - The directory to start recursing fromoperator - The operator to apply to the files recahable from this
directory (and possibly the directories as well)applyOperatorToDirectories - Should the operator be applied to the Directories?
Note! If this is true the directory passed in will
be operated on as well
public static void simpleRecurse(java.io.File directory,
boolean applyOperatorToDirectories,
Operator operator)
public static void growFile(java.io.File file,
byte[] content,
long position)
throws java.io.IOException
java.io.IOException
public static void growFile(java.io.File file,
int length,
long position)
throws java.io.IOException
java.io.IOException
public static void growFile(java.io.File file,
int length,
byte val,
long position)
throws java.io.IOException
java.io.IOException
public static void copy(java.io.File from,
java.io.File to)
throws java.io.IOException
java.io.IOExceptionpublic static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||