serp.util
Class Files
java.lang.Object
|
+--serp.util.Files
- public class Files
- extends Object
Utility operations on files.
Constructor Summary |
Files()
|
Method Summary |
static File |
backup(File file)
Backup the given file to a new file called <file-name>~. |
static File |
getClassFile(Class cls)
Return the class file of the given class, or null if the
class is in a jar. |
static File |
getPackageFile(File base,
String pkg,
boolean mkdirs)
Return the file for the given package. |
static File |
getSourceFile(Class cls)
Return the source file for the given class, or null if the
source is not in the CLASSPATH. |
static File |
revert(File backup)
Revert the given backup file to the original location. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Files
public Files()
backup
public static File backup(File file)
- Backup the given file to a new file called <file-name>~. If
the file does not exist or a backup could not be created, returns null.
revert
public static File revert(File backup)
- Revert the given backup file to the original location. If the given
file's name does not end in '~', the '~' is appended before proceeding.
If the backup file does not exist or could not be reverted,
returns null.
getSourceFile
public static File getSourceFile(Class cls)
- Return the source file for the given class, or null if the
source is not in the CLASSPATH.
getClassFile
public static File getClassFile(Class cls)
- Return the class file of the given class, or null if the
class is in a jar.
getPackageFile
public static File getPackageFile(File base,
String pkg,
boolean mkdirs)
- Return the file for the given package. If the given base directory
matches the given package structure, it will be used as-is. If not,
the package structure will be added beneath the base directory. If
the base directory is null, the current working directory will be
used as the base.
Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.