public class FileUtil extends java.lang.Object
Simple but most commonly used methods of this class are:
- readFile
- concatPath
Other less frequently used but still handy methods are:
- normalizeFileName
to take the current user directory into account via the 'user.dir' system property
Modifier | Constructor and Description |
---|---|
private |
FileUtil()
Utility class which should never instanciate itself.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
concatPath(java.lang.String sPath_,
java.lang.String sFile_)
Concatenates a file path with the file name.
|
static java.lang.String |
getAbsoluteFileName(java.lang.String sFileName_) |
private static boolean |
isAbsolute(java.lang.String sFileName_)
Tests if the file represented by this File object is an absolute
pathname.
|
static java.lang.String |
normalizeFileName(java.lang.String sFile)
This method returns an absolute (canonical)
file name.
|
private static java.lang.String |
normalizeFileName(java.lang.String sFile,
java.lang.String sUserDir)
This method returns an absolute (canonical)
file name.
|
static java.lang.String |
readFile(java.lang.String sFileName_)
Reads a File and returns the content in a String.
|
private FileUtil()
public static java.lang.String concatPath(java.lang.String sPath_, java.lang.String sFile_)
This method is inspired from the FrIJDE project out of the gCollins.File.FileTools class.
FrIJDE Homepage: http://amber.wpi.edu/~thethe/Document/Besiex/Java/FrIJDE/
sPath_
- a directory path. Is not allowed to be null.sFile_
- the base name of a file.public static java.lang.String readFile(java.lang.String sFileName_) throws java.io.IOException, java.io.FileNotFoundException
sFileName_
- the name of the file to read.java.io.FileNotFoundException
- if file does not exist.java.io.IOException
- if any file operation fails.public static java.lang.String getAbsoluteFileName(java.lang.String sFileName_)
public static java.lang.String normalizeFileName(java.lang.String sFile)
private static java.lang.String normalizeFileName(java.lang.String sFile, java.lang.String sUserDir)
private static boolean isAbsolute(java.lang.String sFileName_)