|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jasen.util.FileUtils
General file utility methods.
Nested Class Summary | |
static class |
FileUtils.ExtensionFileFilter
Inner file filter class for listing files of known extension. |
Constructor Summary | |
FileUtils()
|
Method Summary | |
static void |
copy(File source,
File destination)
Convenience file copy method |
static void |
dedupe(File folder,
boolean filename)
Removes (deletes) all duplicate files found in the given folder. |
static void |
dedupe(File folder,
File deposit,
boolean filename)
Removes all duplicate files found in the given folder and moves them to the deposit folder |
static void |
dedupe(File folder,
FileFilter filter,
boolean filename)
Removes (deletes) all duplicate files found in the given folder with the given filter |
static void |
dedupe(File folder,
FileFilter filter,
File deposit,
boolean filename)
Removes duplicate files from the given folder by renaming them to the given extension. |
static String |
fingerPrintFile(File file,
int length)
Creates a distinct "fingerprint" of the given file such that two files with the same content will have the same fingerprint. |
static String |
getAbsolutePathWithoutFile(File pathname)
Gets the absolute path without the file (root path). |
static String |
getFileExtension(File pathname)
Returns the String that occurs after the last "dot" in the filename |
static String |
getFileExtension(String filename)
|
static String |
getFilenameWithoutExtension(String filename)
Gets the name of a file without the extension (text after last dot) |
static String |
getSafePath(String path)
Ensures the path is terminated with a file separator |
static URL[] |
listFiles(File folder,
String extension)
Lists all the files in the given folder with the given extension |
static URL[] |
listJars(File folder)
Lists all the .jar files in the given folder as URL references |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FileUtils()
Method Detail |
public static void dedupe(File folder, boolean filename) throws IOException
folder
- filename
- If true, files with the same root name are considered duplicates irrespective of their fingerprint
IOException
public static void dedupe(File folder, File deposit, boolean filename) throws IOException
folder
- deposit
- filename
- If true, files with the same root name are considered duplicates irrespective of their fingerprint
IOException
public static void dedupe(File folder, FileFilter filter, boolean filename) throws IOException
folder
- filter
- filename
- If true, files with the same root name are considered duplicates irrespective of their fingerprint
IOException
public static void dedupe(File folder, FileFilter filter, File deposit, boolean filename) throws IOException
If extension is null, the duplicate files are deleted.
If more than one duplicate of the same file is found, an integer count is appended to the renamed file.
folder
- The folder in which to look for duplicatesfilter
- The file filter to use when listing filesdeposit
- The path to which duplicates are moved (must be a directory)filename
- If true, files with the same root name are considered duplicates irrespective of their fingerprint
IOException
public static String fingerPrintFile(File file, int length) throws IOException
file
- The file to fingerprintlength
- The length of the fingerprint. The longer the length, the more accurate the fingerprint. NOTE: The size of the actual string returned will be greater than "length" bytes
IOException
public static String getAbsolutePathWithoutFile(File pathname)
pathname
-
public static String getSafePath(String path)
path
-
public static String getFilenameWithoutExtension(String filename)
filename
-
public static String getFileExtension(File pathname)
pathname
-
public static String getFileExtension(String filename)
public static final void copy(File source, File destination) throws IOException
source
- destination
-
IOException
public static URL[] listJars(File folder) throws MalformedURLException
folder
- The folder in which to look
MalformedURLException
public static URL[] listFiles(File folder, String extension) throws MalformedURLException
folder
- The folder in which to lookextension
- The file extension (case sensitive)
MalformedURLException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |