|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openbp.common.io.FileUtil
public final class FileUtil
The FileUtil class provides some additional static file management utility methods not contained in java.io.File. The class contains static method only.
| Field Summary | |
|---|---|
static int |
FILETYPE_ANY
File type 'any file' (argument for list(java.lang.String, java.lang.String, int)) |
static int |
FILETYPE_DIR
File type 'directory' (argument for list(java.lang.String, java.lang.String, int)) |
static int |
FILETYPE_FILE
File type 'file' (argument for list(java.lang.String, java.lang.String, int)) |
| Method Summary | |
|---|---|
static java.lang.String |
constructFileName(java.lang.String dir,
java.lang.String name,
java.lang.String extension)
Constructs a file name from a directory and extension specification. |
static void |
copy(java.io.File src,
java.io.File dest)
Copy a file or directory. |
static void |
copy(java.io.File src,
java.io.File dest,
java.io.FilenameFilter filter)
Copy a file or directory using a file name filter. |
static java.io.File |
createTempFile(java.lang.String directory,
java.lang.String prefix,
java.lang.String suffix,
java.lang.String extension)
Determines the full path name for a temporary file. |
static boolean |
deleteFile(java.io.File f,
java.io.FilenameFilter filter)
Deletes a file or a directory. |
static java.lang.String |
getBaseName(java.lang.String pathName)
Gets the base name (file name without directory path and extension) of a path name. |
static java.lang.String |
getBaseNameWithExtension(java.io.File file)
Gets the base name (file name without directory path but with extension) of a path name. |
static java.lang.String |
getBaseNameWithExtension(java.lang.String pathName)
Gets the base name (file name without directory path but with extension) of a path name. |
static java.lang.String |
getDirectoryFromFilePath(java.lang.String filePath)
Gets the full path name of the directory from a file path specification. |
static java.io.File |
getParent(java.io.File f,
boolean returnCurrent)
File.getParent() can return null when the file is specified without a directory or is in the root directory. |
static java.lang.String |
getRelativePath(java.lang.String startPath,
java.lang.String targetPath)
Returns the relative path between two different files. |
static java.lang.String |
getRelativePathToParentDir(java.lang.String target,
java.lang.String origin)
Determines the relative path from the given origin path name to the given target path name, assuming that the target is a sub directory of the origin. |
static java.lang.String[] |
list(java.lang.String dirName,
java.lang.String pattern,
int fileType)
Returns an array of strings naming the files and directories in a directory, matching the files against an optional pattern and file type. |
static void |
main(java.lang.String[] args)
Main method for test purposes. |
static void |
remove(java.io.File src)
Recursively removes a file or directory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int FILETYPE_ANY
list(java.lang.String, java.lang.String, int))
public static final int FILETYPE_FILE
list(java.lang.String, java.lang.String, int))
public static final int FILETYPE_DIR
list(java.lang.String, java.lang.String, int))
| Method Detail |
|---|
public static java.lang.String[] list(java.lang.String dirName,
java.lang.String pattern,
int fileType)
dirName - Name of the directory or null for the current directorypattern - Wildcard pattern (see the ShellMatcher class)fileType - Type of file to be listed (FILETYPE_ANY/FILETYPE_FILE/FILETYPE_DIR)
KNOWN BUG: It seems that on Win32 systems, it does always return
all files and directories matching pattern, regardless of fileType.
java.lang.SecurityException - If a security manager exists and denies read access to the directory
public static void remove(java.io.File src)
throws java.io.IOException
src - File or directory to delete
java.io.IOException - If the file could not be deleted
public static void copy(java.io.File src,
java.io.File dest)
throws java.io.IOException
src - Source file or directorydest - Destination file or directory
java.io.IOException - If the operation fails
public static void copy(java.io.File src,
java.io.File dest,
java.io.FilenameFilter filter)
throws java.io.IOException
src - Source file or directorydest - Destination file or directoryfilter - File name filter that determines which files of a directory will be copied
java.io.IOException - If the operation fails
public static boolean deleteFile(java.io.File f,
java.io.FilenameFilter filter)
f - The file to deletefilter - The file name filter
public static java.lang.String getBaseNameWithExtension(java.io.File file)
file - The file
public static java.lang.String getBaseNameWithExtension(java.lang.String pathName)
pathName - The path name of the file
public static java.lang.String getBaseName(java.lang.String pathName)
pathName - The path name of the file
public static java.lang.String getDirectoryFromFilePath(java.lang.String filePath)
filePath - Path specification of the file
public static java.lang.String getRelativePathToParentDir(java.lang.String target,
java.lang.String origin)
getRelativePath(java.lang.String, java.lang.String) method.
target - Absolute path of the target path (the sub directory, example: "d:\Src\framework\skyfw")origin - Absolute path of the origin path (the base directory, example: "d:\Src")
public static java.lang.String getRelativePath(java.lang.String startPath,
java.lang.String targetPath)
startPath - The start directorytargetPath - The directory which should be reached by appending the resulting relative
path to the start directory.
java.lang.IllegalArgumentException - if one of the arguments is null or a relative path
public static java.lang.String constructFileName(java.lang.String dir,
java.lang.String name,
java.lang.String extension)
dir - Directory to place the file inname - Base name of the fileextension - The file name extension
public static java.io.File createTempFile(java.lang.String directory,
java.lang.String prefix,
java.lang.String suffix,
java.lang.String extension)
prefix - Prefix for temporary file name or nullsuffix - Suffix for temporary file name or nulldirectory - Directory of temporary fileextension - Extension of temporary file or null
public static java.io.File getParent(java.io.File f,
boolean returnCurrent)
f - The target File to analyzereturnCurrent - true Returns a file object (the current directory) also if the file does not
contain a path specification.public static void main(java.lang.String[] args)
args - Argument array
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||