|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.lucidviews.util.io.Streams
net.lucidviews.util.io.Files
A collection of methods for manipualting Files.
| Nested Class Summary | |
static class |
Files.NewFileNameModel
|
| Field Summary | |
private static java.lang.String |
DEFAULT_PATH_SEPARATOR
The character used to separate folder paths in the classpath. |
| Fields inherited from class net.lucidviews.util.io.Streams |
DEFAULT_BUFFER_SIZE |
| Constructor Summary | |
protected |
Files()
Suppresses default constructor, ensuring non-instantiability. |
| Method Summary | |
static java.io.File |
copyFile(java.io.File original,
java.io.File destination)
Copy a file to a given folder or file location. |
static java.io.File |
copyFile(java.io.File original,
java.io.File destination,
int bufferSize)
Copy a file to a given folder or file location. |
static java.io.File |
copyFile(java.io.File original,
java.io.File destinationFolder,
java.lang.String fileName)
Copy a file to a folder, giving the copy a new name. |
static java.io.File |
copyFile(java.io.File original,
java.io.File destinationFolder,
java.lang.String fileName,
int bufferSize)
Copy a file to a folder, giving the copy a new name. |
static boolean |
copyFolder(java.io.File original,
java.io.File destination)
Copy a folder, and all its contents, to another location. |
static boolean |
copyFolder(java.io.File original,
java.io.File destination,
java.io.FileFilter filter)
Copy a folder, and all its contents, to another location. |
static boolean |
copyFolder(java.io.File original,
java.io.File destination,
java.io.FilenameFilter filter)
Copy a folder, and all its contents, to another location. |
static boolean |
copyFolderContents(java.io.File original,
java.io.File destination)
Copy the contents of a folder to another location. |
static boolean |
copyFolderContents(java.io.File original,
java.io.File destination,
java.io.FileFilter filter)
Copy the contents of a folder to another location. |
static boolean |
copyFolderContents(java.io.File original,
java.io.File destination,
java.io.FilenameFilter filter)
Copy the contents of a folder to another location. |
static java.io.File |
createNewFile(java.io.File folder,
java.lang.String preferredFileName)
Create a new, blank file in the given folder. |
static java.io.File |
createNewFile(java.lang.String fileName,
java.io.File folder)
Create a new, blank file with a given name. |
static java.util.List |
createPatch(java.io.File currentFolder,
boolean recursive,
java.io.File oldFolder,
java.io.File destFolder)
Create a patch for an old set of files. |
static java.util.List |
createPatch(java.io.File currentFolder,
boolean recursive,
java.io.File oldFolder,
java.io.File destFolder,
boolean patchModifiedFiles)
Create a patch for an old set of files. |
static java.util.List |
createPatch(java.io.File currentFolder,
boolean recursive,
java.io.File oldFolder,
java.io.File destFolder,
boolean patchModifiedFiles,
java.util.Comparator fileComparator)
Create a patch for an old set of files. |
static java.util.List |
createPatch(java.io.File currentFolder,
java.io.File oldFolder,
java.io.File destFolder)
Create a patch for an old set of files. |
static java.util.List |
createPatch(java.io.File currentFolder,
java.io.File oldFolder,
java.io.File destFolder,
boolean patchModifiedFiles)
Create a patch for an old set of files. |
static boolean |
deleteFolder(java.io.File folder)
Delete a folder and all files and sub-folders. |
static java.io.File |
findFile(java.lang.String fileName)
Find a file with the given name, located somewhere on the classpath. |
static boolean |
isDescendant(java.io.File folder,
java.io.File suspectedChild)
Checks if the suspectedChild file (or folder) is contained
within the specified folder or one of its sub-folders. |
static boolean |
isDuplicate(java.io.File file,
java.io.File compare)
Checks if one file is a duplicate of another. |
static java.util.List |
listFiles(java.io.File folder,
java.util.Comparator comparator)
Get a sorted list of files for a given directory. |
static java.util.List |
listFiles(java.io.File folder,
java.io.FileFilter filter,
java.util.Comparator comparator)
Get a filtered, sorted list of files for a given directory. |
static java.util.List |
listFiles(java.io.File folder,
java.io.FilenameFilter filter,
java.util.Comparator comparator)
Get a filtered, sorted list of files for a given directory. |
static java.util.List |
sortFiles(java.io.File[] files,
java.util.Comparator comparator)
Convert an array of Files to a sorted List. |
| Methods inherited from class net.lucidviews.util.io.Streams |
close, close, compare, compare, pipe, pipe |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static final java.lang.String DEFAULT_PATH_SEPARATOR
| Constructor Detail |
protected Files()
| Method Detail |
public static java.io.File findFile(java.lang.String fileName)
throws java.io.FileNotFoundException
fileName - the name of the file
File with the given name, located somewhere on the
classpath, the object is guaranteed to be non-null and
the file is guaranteed to exist
java.io.FileNotFoundException - if the file could not be found on the
classpath
public static boolean isDuplicate(java.io.File file,
java.io.File compare)
throws java.io.IOException
file - file to testcompare - second file to compare the file to
true if the two files are the same
java.io.IOException - error reading content of the two files being compared
public static boolean isDescendant(java.io.File folder,
java.io.File suspectedChild)
suspectedChild file (or folder) is contained
within the specified folder or one of its sub-folders.
false (not a descendant).
folder - the folder that could be the parent or grand-parentsuspectedChild - the file or folder that is suspected to be a
descendant
true if the suspectedChild is a
descendant of the folder
public static java.io.File createNewFile(java.io.File folder,
java.lang.String preferredFileName)
throws java.io.IOException
folder. The file will have a name
based on the preferredFileName. If a file with the
preferred name already exists then a numeric suffix will be added (e.g.
./filename_2.dat).
folder - the directory where the new file is to be createdpreferredFileName - the desired name of the file
File reference to a new file in the given folder
java.io.IOException - error creating the new file
java.lang.SecurityException - access to write the file was denied by the system
security manager
public static java.io.File createNewFile(java.lang.String fileName,
java.io.File folder)
throws java.io.IOException
fileName. The file will be placed within
folder, either directly in that folder or in a sub-folder.
If a file with the preferred name already exists then a sub-folder will
be created with a numeric suffix (e.g.
./filename_2/filename_2.dat).
fileName - the name of the new filefolder - the desired directory where the new file is to be created
File reference to a new file in the given folder
java.io.IOException - error creating the new file
java.lang.SecurityException - access to write the file was denied by the system
security manager
public static java.util.List sortFiles(java.io.File[] files,
java.util.Comparator comparator)
Files to a sorted List.
Comparator.
files - an array of Filecomparator - the Comparator used to sort the files
List of sorted Files
java.lang.ClassCastException - the specified comparator was not
compatible with File objects
java.lang.UnsupportedOperationException - the generated List did
not support a sort operationFileComparator
public static java.util.List listFiles(java.io.File folder,
java.util.Comparator comparator)
folder - the folder whose contents are to be listedcomparator - a Comparator that will sort the files
List of Files
java.lang.SecurityException - read access to the folder was denied
java.lang.ClassCastException - the specified comparator was not
compatible with File objects
java.lang.UnsupportedOperationException - the generated List did
not support a sort operationFileComparator
public static java.util.List listFiles(java.io.File folder,
java.io.FilenameFilter filter,
java.util.Comparator comparator)
folder - the folder whose contents are to be listedfilter - a filter that determines which files are added to the listcomparator - a Comparator that will sort the files
List of Files
java.lang.SecurityException - read access to the folder was denied
java.lang.ClassCastException - the specified comparator was not
compatible with File objects
java.lang.UnsupportedOperationException - the generated List did
not support a sort operationFilenameFilter,
FileComparator
public static java.util.List listFiles(java.io.File folder,
java.io.FileFilter filter,
java.util.Comparator comparator)
folder - the folder whose contents are to be listedfilter - a filter that determines which files are added to the listcomparator - a Comparator that will sort the files
List of Files
java.lang.SecurityException - read access to the folder was denied
java.lang.ClassCastException - the specified comparator was not
compatible with File objects
java.lang.UnsupportedOperationException - the generated List did
not support a sort operationFileFilter,
FileComparator
public static java.io.File copyFile(java.io.File original,
java.io.File destination,
int bufferSize)
throws java.io.IOException
File can reference either a directory or a
file. In the case of a directory, a copy of the original file will be
placed in this directory with the same name. If a file is specified, the
destination file will be overwritten with the file at the
original location.
original - the file to be copieddestination - the destination of the copy - either a file or a directorybufferSize - the size of the buffer to use when copying the data
java.lang.SecurityException - error creating a new file
java.io.IOException - error copying the content of the file
public static java.io.File copyFile(java.io.File original,
java.io.File destination)
throws java.io.IOException
destination File can reference either a
directory or a file. In the case of a directory, a copy of the original
file will be placed in this directory with the same name. If a file is
specified, the destination file will be overwritten with the file at the
original location.
original - the file to be copieddestination - the destination of the copy - either a file or a
directory
java.lang.SecurityException - error creating a new file
java.io.IOException - error copying the content of the file
public static java.io.File copyFile(java.io.File original,
java.io.File destinationFolder,
java.lang.String fileName,
int bufferSize)
throws java.io.IOException
original - the file to be copieddestinationFolder - the folder where the file is to be copied tofileName - the name of the new copybufferSize - the size of the buffer to use when copying the data
java.lang.SecurityException - error creating a new file
java.io.IOException - error copying the content of the file
public static java.io.File copyFile(java.io.File original,
java.io.File destinationFolder,
java.lang.String fileName)
throws java.io.IOException
original - the file to be copieddestinationFolder - the folder where the file is to be copied tofileName - the name of the new copy
java.lang.SecurityException - error creating a new file
java.io.IOException - error copying the content of the file
public static boolean copyFolder(java.io.File original,
java.io.File destination,
java.io.FilenameFilter filter)
destination folder already contains a folder with the
same name as the original then the contents of the
original folder will be merged into that folder, overwriting
any writable files already in the destination (read-only
files will not be overwritten, but will cause this copy to be incomplete,
acknowledged by a false return value).
original folder. If one file or folder cannot be copied the
routine will continue copying the remaining contents.
true if all files and sub-folders were
successfully copied. This method returns false if any file or
folder could not be deleted.
true indicates the
destination folder will be an exact copy of the
original.
• A return value of false indicates the
destination folder may not exist.
• In the case of a security exception, there is no guarantee as
to which files have been copied, including the root folder.
original - the folder to be copieddestination - the folder where the original folder is to be copied tofilter - a filter used to choose which files to copy
true if the folder and its contents were copied
successfully, false otherwise
public static boolean copyFolder(java.io.File original,
java.io.File destination,
java.io.FileFilter filter)
destination folder already contains a folder with the
same name as the original then the contents of the
original folder will be merged into that folder, overwriting
any writable files already in the destination (read-only
files will not be overwritten, but will cause this copy to be incomplete,
acknowledged by a false return value).
original folder. If one file or folder cannot be copied the
routine will continue copying the remaining contents.
true if all files and sub-folders were
successfully copied. This method returns false if any file or
folder could not be deleted.
true indicates the
destination folder will be an exact copy of the
original.
• A return value of false indicates the
destination folder may not exist.
• In the case of a security exception, there is no guarantee as
to which files have been copied, including the root folder.
original - the folder to be copieddestination - the folder where the original folder is to be copied tofilter - a filter used to choose which files to copy
true if the folder and its contents were copied
successfully, false otherwise
public static boolean copyFolder(java.io.File original,
java.io.File destination)
destination folder already contains a folder with the
same name as the original then the contents of the
original folder will be merged into that folder, overwriting
any writable files already in the destination (read-only
files will not be overwritten, but will cause this copy to be incomplete,
acknowledged by a false return value).
original folder. If one file or folder cannot be copied the
routine will continue copying the remaining contents.
true if all files and sub-folders were
successfully copied. This method returns false if any file or
folder could not be deleted.
true indicates the
destination folder will be an exact copy of the
original.
• A return value of false indicates the
destination folder may not exist.
• In the case of a security exception, there is no guarantee as
to which files have been copied, including the root folder.
original - the folder to be copieddestination - the folder where the original folder is to be copied to
true if the folder and its contents were copied
successfully, false otherwise
public static boolean copyFolderContents(java.io.File original,
java.io.File destination,
java.io.FilenameFilter filter)
original folder will overwrite any
writable files already in the destination (read-only files
will not be overwritten, but will cause this copy to be incomplete,
acknowledged by a false return value).
original folder. If one file or folder cannot be copied the
routine will continue copying the remaining contents.
true if all files and sub-folders were
successfully copied. This method returns false if any file or
folder could not be deleted.
true indicates the
destination folder will contain all the files and folder in
the original.
• A return value of false indicates the
destination folder may not contain any of the files or folders
from the original.
• In the case of a security exception, there is no guarantee as
to which files have been copied.
original - the folder whose content is to be copieddestination - the folder where the content is to be copied tofilter - a filter used to choose which files to copy
true if the contents were copied successfully,
false otherwise
public static boolean copyFolderContents(java.io.File original,
java.io.File destination,
java.io.FileFilter filter)
original folder will overwrite any
writable files already in the destination (read-only files
will not be overwritten, but will cause this copy to be incomplete,
acknowledged by a false return value).
original folder. If one file or folder cannot be copied the
routine will continue copying the remaining contents.
true if all files and sub-folders were
successfully copied. This method returns false if any file or
folder could not be deleted.
true indicates the
destination folder will contain all the files and folder in
the original.
• A return value of false indicates the
destination folder may not contain any of the files or folders
from the original.
• In the case of a security exception, there is no guarantee as
to which files have been copied.
original - the folder whose content is to be copieddestination - the folder where the content is to be copied tofilter - a filter used to choose which files to copy
true if the contents were copied successfully,
false otherwise
public static boolean copyFolderContents(java.io.File original,
java.io.File destination)
original folder will overwrite any
writable files already in the destination (read-only files
will not be overwritten, but will cause this copy to be incomplete,
acknowledged by a false return value).
original folder. If one file or folder cannot be copied the
routine will continue copying the remaining contents.
true if all files and sub-folders were
successfully copied. This method returns false if any file or
folder could not be deleted.
true indicates the
destination folder will contain all the files and folder in
the original.
• A return value of false indicates the
destination folder may not contain any of the files or folders
from the original.
• In the case of a security exception, there is no guarantee as
to which files have been copied.
original - the folder whose content is to be copieddestination - the folder where the content is to be copied to
true if the contents were copied successfully,
false otherwisepublic static boolean deleteFolder(java.io.File folder)
true if all files and sub-folders were
successfully deleted. This method returns false if any file or
folder could not be deleted.
true indicates the
folder will no longer exist.
• A return value of false indicates the
folder will still exist, however there is no guarantee that
any of its files or sub-folders will still exist.
• In the case of a security exception, there is no guarantee as
to which files have been deleted, including the specified
folder.
folder - the folder to be deleted
java.lang.SecurityException - delete access to the folder was denied by the
security manager
public static java.util.List createPatch(java.io.File currentFolder,
java.io.File oldFolder,
java.io.File destFolder)
currentFolder - the root folder containing the current set of files
(latest version)oldFolder - the root folder containing the old set of filesdestFolder - the folder where the patch is to be created (this folder
need not exist, it will automatically be created) it is
recommended the folder either does not exist or is empty
before this method is called
List of File references to files in the
'current' folder that could not be copied/included in the patch due
to an I/O exception - the value is never null - always
check the list is empty to ensure the patch was complete
public static java.util.List createPatch(java.io.File currentFolder,
java.io.File oldFolder,
java.io.File destFolder,
boolean patchModifiedFiles)
patchModifiedFiles parameter to true. (The
definition of 'modified' being those files whose timestamp is more recent
than the old copy of the file).
currentFolder - the root folder containing the current set of files
(latest version)oldFolder - the root folder containing the old set of filesdestFolder - the folder where the patch is to be created (this folder
need not exist, it will automatically be created) it is
recommended the folder either does not exist or is empty
before this method is calledpatchModifiedFiles - indicates if modified files should be included
in the patch
List of File references to files in the
'current' folder that could not be copied/included in the patch due
to an I/O exception - the value is never null - always
check the list is empty to ensure the patch was complete
public static java.util.List createPatch(java.io.File currentFolder,
boolean recursive,
java.io.File oldFolder,
java.io.File destFolder)
recursive parameter to true. It will
automatically include modified files in the patch. (The definition of
'modified' being those files whose timestamp is more recent than the old
copy of the file).
currentFolder - the root folder containing the current set of files
(latest version)recursive - indicates if the patch should include sub-foldersoldFolder - the root folder containing the old set of filesdestFolder - the folder where the patch is to be created (this folder
need not exist, it will automatically be created) it is
recommended the folder either does not exist or is empty
before this method is called
List of File references to files in the
'current' folder that could not be copied/included in the patch due
to an I/O exception - the value is never null - always
check the list is empty to ensure the patch was complete
public static java.util.List createPatch(java.io.File currentFolder,
boolean recursive,
java.io.File oldFolder,
java.io.File destFolder,
boolean patchModifiedFiles)
recursive parameter to true. It will only
include modified files in the patch if instructed to, by setting the
patchModifiedFiles parameter to true. (The
definition of 'modified' being those files whose timestamp is more recent
than the old copy of the file).
currentFolder - the root folder containing the current set of files
(latest version)recursive - indicates if the patch should include sub-foldersoldFolder - the root folder containing the old set of filesdestFolder - the folder where the patch is to be created (this folder
need not exist, it will automatically be created) it is
recommended the folder either does not exist or is empty
before this method is calledpatchModifiedFiles - indicates if modified files should be included
in the patch
List of File references to files in the
'current' folder that could not be copied/included in the patch due
to an I/O exception - the value is never null - always
check the list is empty to ensure the patch was complete
public static java.util.List createPatch(java.io.File currentFolder,
boolean recursive,
java.io.File oldFolder,
java.io.File destFolder,
boolean patchModifiedFiles,
java.util.Comparator fileComparator)
recursive parameter to true. It will only
include modified files in the patch if instructed to, by setting the
patchModifiedFiles parameter to true.
fileComparator. If the fileComparator concludes
the current file is 'greater' than the old file, then the file is
considered more recent and therefore needs replacing.
currentFolder - the root folder containing the current set of files
(latest version)recursive - indicates if the patch should include sub-foldersoldFolder - the root folder containing the old set of filesdestFolder - the folder where the patch is to be created (this folder
need not exist, it will automatically be created) it is
recommended the folder either does not exist or is empty
before this method is calledpatchModifiedFiles - indicates if modified files should be included
in the patchfileComparator - the comparator used to determine which file is more
recent and therefore if it needs to be patched
List of File references to files in the
'current' folder that could not be copied/included in the patch due
to an I/O exception - the value is never null - always
check the list is empty to ensure the patch was complete
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||