|
Lightweight Bartering Grid | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlbg.common.io.CommonFileHandling
public abstract class CommonFileHandling
A CommonFileHandling provides common File handling routines.
Field Summary | |
---|---|
static java.lang.String |
CLASS_EXT
Class file default extension. |
static java.lang.String |
CSV_EXT
CSV spreadsheet file default extension. |
static java.lang.String |
FILE_SEP
Filesystem file separator (i.e. |
static java.lang.String |
JAR_EXT
JAR file default extension. |
static java.lang.String |
LOG_EXT
Log file default extension. |
static java.lang.String |
LOG_PREFIX
Log file default prefix. |
static java.lang.String |
OUTPUT_DATA_EXT
Output data file default extension. |
static java.lang.String |
PDF_EXT
PDF file default extension. |
static java.lang.String |
TXT_EXT
Text file default extension. |
Constructor Summary | |
---|---|
CommonFileHandling()
|
Method Summary | |
---|---|
static void |
closeBR(java.io.BufferedReader br,
java.lang.String fn)
Closes target BufferedReader encapsulating target filename. |
static void |
copyFile(java.lang.String fn1,
java.lang.String fn2)
Copies target source file to target destination file. |
static void |
createDirectory(java.lang.String target_dir)
Creates a new directory. |
static boolean |
dump(java.lang.Object obj)
Dumps target Object to standard output. |
static boolean |
dumpSeparator()
Dumps separating line to System console standard output. |
static java.lang.String |
extractBaseFileNameFromFileName(java.lang.String fn,
java.lang.String ext)
Extracts base file name (without extension) from target file name without complete path. |
static java.lang.String |
extractBaseFileNameFromPath(java.lang.String fn,
java.lang.String ext)
Extracts base file name (without extension) from target file name with complete path. |
static java.lang.String |
extractFileNameFromPath(java.lang.String fn)
Extracts file name from target file name with complete path. |
static java.lang.String |
extractMainClass(java.lang.String jarfn)
Extracts the main class of the target jar file's embedded manifest. |
static java.io.File |
getFirstMatchingFile(java.io.File f)
Returns The first non-existing file matching the original one. |
static boolean |
isAbsolutePath(java.lang.String path)
Checks if target path is absolute. |
static boolean |
isCSVFileName(java.lang.String fn)
Checks if target file name is a CSV spreadsheet file name. |
static boolean |
isJarFileName(java.lang.String fn)
Checks if target file name is a Java archive file name. |
static boolean |
isLogFilename(java.lang.String fn)
Checks if target file name is a log file name. |
static boolean |
isPDFFileName(java.lang.String fn)
Checks if target file name is a PDF file name. |
static boolean |
isTextFileName(java.lang.String fn)
Checks if target file name is a text file name. |
static java.util.Properties |
loadProperties(java.lang.String fn)
Loads Properties from target text file. |
static java.io.BufferedReader |
openBR(java.lang.String fn)
Opens a BufferedReader encapsulating target filename. |
static java.lang.String |
readFile(java.lang.String fn)
Reads text file contents given target filename. |
static java.lang.String |
readFile(java.lang.String fn,
boolean dont_complain)
Reads text file contents given target filename. |
static java.lang.String |
readLine(java.io.BufferedReader br,
java.lang.String fn)
Reads one text line from target BufferedReader encapsulating target filename. |
static void |
removeDirectory(java.lang.String target_dir)
Recursively removes a directory and all its contents, including subdirectories. |
static void |
removeDirectory(java.lang.String target_dir,
boolean fail_silently)
Recursively removes a directory and all its contents, including subdirectories. |
static void |
writeFile(java.io.File f,
java.lang.String data)
Writes target data to target file. |
static boolean |
writeFile(java.lang.String fn,
java.lang.String data)
Writes target data to target file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String FILE_SEP
public static final java.lang.String CLASS_EXT
public static final java.lang.String CSV_EXT
public static final java.lang.String JAR_EXT
public static final java.lang.String LOG_EXT
public static final java.lang.String LOG_PREFIX
public static final java.lang.String OUTPUT_DATA_EXT
public static final java.lang.String PDF_EXT
public static final java.lang.String TXT_EXT
Constructor Detail |
---|
public CommonFileHandling()
Method Detail |
---|
public static java.io.BufferedReader openBR(java.lang.String fn) throws GridException
fn
- target filename
GridException
- if target file cannot be openedpublic static void closeBR(java.io.BufferedReader br, java.lang.String fn) throws GridException
br
- target encapsulating BufferedReaderfn
- target filename
GridException
- if target file cannot be closedpublic static java.lang.String readLine(java.io.BufferedReader br, java.lang.String fn) throws GridException
br
- target encapsulating BufferedReaderfn
- target filename
GridException
- if current line cannot be readpublic static java.lang.String readFile(java.lang.String fn) throws GridException
fn
- target filename
GridException
- if a parameter is illegal,
or if an error occurs while reding the filepublic static java.lang.String readFile(java.lang.String fn, boolean dont_complain) throws GridException
fn
- target filenamedont_complain
- if true, no Exception will be thrown,
and null will be returned
GridException
- if dont_complain is false,
and either a parameter is illegal,
or an error occurs while reding the filepublic static boolean writeFile(java.lang.String fn, java.lang.String data) throws GridException
fn
- target filenamedata
- target data
GridException
- if target data cannot be writtenpublic static void writeFile(java.io.File f, java.lang.String data) throws GridException
f
- target filedata
- target data
GridException
- if target data cannot be writtenpublic static void copyFile(java.lang.String fn1, java.lang.String fn2) throws GridException
fn1
- target source filenamefn2
- target destination filename
GridException
- if an error occurs
while copying the filepublic static java.io.File getFirstMatchingFile(java.io.File f)
Files are checked in a wget fashion. If the supplied files doesn't exist, it is returned. If it exists, a new file of the same name, but with a ".0" appended to it. As long as the files exist, the suffix will be incremented, returning the first non-existing file.
For example, if the files "foo", "foo.0" and "foo.2" exist, this
method applied to new File("foo")
will return a
File("foo.1")
f
- base file
public static void createDirectory(java.lang.String target_dir) throws GridException
target_dir
- target directory to create
GridException
- if a parameter is illegalpublic static void removeDirectory(java.lang.String target_dir) throws GridException
target_dir
- target directory to remove
GridException
- if a parameter is illegalpublic static void removeDirectory(java.lang.String target_dir, boolean fail_silently) throws GridException
target_dir
- target directory to removefail_silently
- if true, no GridException is thrown
GridException
- if a parameter is illegalpublic static java.util.Properties loadProperties(java.lang.String fn) throws GridException
fn
- target text filename
GridException
- if an error occurs
while loading the Properties text filepublic static boolean dump(java.lang.Object obj)
obj
- target Object to dump to standard output
public static boolean dumpSeparator()
public static java.lang.String extractFileNameFromPath(java.lang.String fn) throws GridException
fn
- target file name with complete path
GridException
- if target file name with complete path
is illegalpublic static java.lang.String extractBaseFileNameFromFileName(java.lang.String fn, java.lang.String ext) throws GridException
fn
- target file name without complete pathext
- target extension
GridException
- if target file name without complete path
or target extension is illegalpublic static java.lang.String extractBaseFileNameFromPath(java.lang.String fn, java.lang.String ext) throws GridException
fn
- target file name with complete pathext
- target extension
GridException
- if target file name with complete path
or target extension is illegalpublic static boolean isAbsolutePath(java.lang.String path)
path
- target path to check
File.isAbsolute()
public static boolean isJarFileName(java.lang.String fn)
fn
- target file name
public static boolean isTextFileName(java.lang.String fn)
fn
- target file name
public static boolean isCSVFileName(java.lang.String fn)
fn
- target file name
public static boolean isPDFFileName(java.lang.String fn)
fn
- target file name
public static boolean isLogFilename(java.lang.String fn)
fn
- target file name
public static java.lang.String extractMainClass(java.lang.String jarfn) throws GridException
jarfn
- target jar file name
GridException
- if a parameter is illegal,
or if the target jar cannot be processed
|
Lightweight Bartering Grid | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (c) 2005-2008, Cyril Briquet, parts Xavier Dalem.