|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.stringer.util.FileKit
Provides a set of static methods that help with file manipulation.
| Field Summary | |
private static org.apache.log4j.Logger |
logger
|
| Constructor Summary | |
private |
FileKit()
This class has a private constructor to prevent it from being instantiated. |
| Method Summary | |
static java.lang.String |
appendSeparator(java.lang.String path)
Append a file separator to path if it does not have a
trailing one. |
static void |
copy(java.io.File source,
java.io.File dest)
Copies source to destination. |
static java.io.File |
createUnique(java.lang.String filename)
Creates a unique file by inserting digits into filename. |
static java.io.File |
createUnique(java.lang.String path,
java.lang.String filename)
Creates a unique file in by inserting digits into filename. |
static java.lang.String |
directories(java.lang.String dirs)
|
static java.lang.String |
directory(java.lang.String dir)
|
static boolean |
exists(java.lang.String filename)
Returns true, if filename exists; false, otherwise. |
static java.lang.String |
getExtension(java.io.File file)
|
static java.lang.String |
getExtension(java.lang.String filename)
Extract the extension from a filename. |
static java.lang.String |
getHomeDir()
Returns the absolute path of the ~/.stringer/ directory. |
static java.lang.String |
getHomeDir(java.lang.String subdir)
Checks for existence of .stringer folder in the user's home directory and returns the absolute path with a file separator appended. |
static java.lang.String |
getUniqueName(java.lang.String filename)
Creates unique filename. |
static java.lang.String |
getUniqueName(java.lang.String filename,
java.lang.String infix)
|
static boolean |
move(java.io.File source,
java.io.File dest)
Move a file from source to destination. |
static java.io.File |
moveUnique(java.io.File file,
java.lang.String path)
Move a file to path. |
static java.io.File |
moveUnique(java.io.File file,
java.lang.String path,
java.lang.String filename)
Moves file to path but renames
filename if it already exists in the target path. |
static java.lang.String |
name(java.lang.String filename)
|
static void |
readBinary(java.io.File file,
java.util.Collection c)
Reads all objects from file using serialization and adds
them to c. |
static java.io.File |
setExtension(java.io.File file,
java.lang.String ext)
Appends the specified extension to a file if it is not already there. |
static void |
shorten(java.io.File file,
long bytes)
Shortens file by bytes bytes. |
static void |
writeBinary(java.io.File file,
java.util.Collection c)
Write all items in c to file using
serialization. |
static void |
writeProperties(java.io.File file,
java.util.Properties props)
Stores props in file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static org.apache.log4j.Logger logger
| Constructor Detail |
private FileKit()
| Method Detail |
public static java.io.File createUnique(java.lang.String filename)
throws java.io.IOException
filename.
This using the filename argument as a pattern to create a unique
filename. If the pattern looks like "subscription.xml" the unique
filename of the File returned will look like "subscription.1.xml".
java.io.IOException
public static java.io.File createUnique(java.lang.String path,
java.lang.String filename)
throws java.io.IOException
filename.
path - the path to a directory in the file system to createfilename - the template filename of the file to be created
java.io.IOException
public static java.io.File moveUnique(java.io.File file,
java.lang.String path,
java.lang.String filename)
throws java.io.IOException
file to path but renames
filename if it already exists in the target path.
file - the file to be movedpath - the file is moved to this location in the file system.filename - the new filename for file
java.io.IOException
public static boolean move(java.io.File source,
java.io.File dest)
throws java.io.IOException
source to destination.
An attempt is made to simply rename the file to the destination
and if that fails, the file is copied to the destination and the
source is then removed.
java.io.IOException
public static java.io.File moveUnique(java.io.File file,
java.lang.String path)
throws java.io.IOException
file to path.
java.io.IOException
public static void copy(java.io.File source,
java.io.File dest)
throws java.io.IOException
source to destination.
If dest already exists it is overwritten.
source - the source filedest - the destination file
java.io.IOExceptionpublic static java.lang.String name(java.lang.String filename)
filename - the filename to be processed.
public static java.lang.String getExtension(java.lang.String filename)
filename - the filename to be processed.
public static java.lang.String getExtension(java.io.File file)
public static java.io.File setExtension(java.io.File file,
java.lang.String ext)
file - The extension of this file is set to extext - the extension to add to file
public static boolean exists(java.lang.String filename)
public static final java.lang.String getHomeDir(java.lang.String subdir)
subdir - a sub directory that is located in ~/.stringer/ or created
if it does not exist
public static final java.lang.String getHomeDir()
public static java.lang.String appendSeparator(java.lang.String path)
path if it does not have a
trailing one.
public static java.lang.String directory(java.lang.String dir)
public static java.lang.String directories(java.lang.String dirs)
public static void shorten(java.io.File file,
long bytes)
file by bytes bytes.
public static void writeProperties(java.io.File file,
java.util.Properties props)
throws java.io.IOException
props in file.
java.io.IOException
public static void readBinary(java.io.File file,
java.util.Collection c)
throws java.io.IOException
file using serialization and adds
them to c.
java.io.IOException
public static void writeBinary(java.io.File file,
java.util.Collection c)
throws java.io.IOException
c to file using
serialization.
java.io.IOExceptionpublic static java.lang.String getUniqueName(java.lang.String filename)
public static java.lang.String getUniqueName(java.lang.String filename,
java.lang.String infix)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||