public class FileUtilLimitedImpl extends AbstractLoggableComponent implements FileUtilLimited
File handling and manipulation.getInstance()| Modifier and Type | Field and Description |
|---|---|
protected static String |
HOME_ROOT
The typical home directory of the user "root" under Unix/Linux.
|
private static FileUtilLimited |
instance |
NO_FILES, PATH_SEGMENT_CURRENT, PATH_SEGMENT_PARENT, PROPERTY_TMP_DIR, PROPERTY_USER_HOME| Constructor and Description |
|---|
FileUtilLimitedImpl()
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getBasename(String filename)
This method gets the basename of the given
filename (path). |
String |
getDirname(String filename)
This method gets the directory-name of the given
filename (path). |
String |
getExtension(String filename)
This method extracts the extension from the given
filename. |
static FileUtilLimited |
getInstance()
This method gets the singleton instance of this
FileUtilLimitedImpl. |
protected String |
getUserHomeDirectoryPath() |
protected String |
getUserLogin() |
protected String |
normalizeHome(String path)
Normalize the potential home segment of the path (if starts with ~ such as "~/.ssh", "~root/" or "~admin/..").
|
String |
normalizePath(String path)
|
String |
normalizePath(String path,
char separator)
This method normalizes a given
path. |
createLogger, doInitialize, getLoggerdoInitialized, getInitializationState, initializeprotected static final String HOME_ROOT
private static FileUtilLimited instance
public static FileUtilLimited getInstance()
FileUtilLimitedImpl. Cdi.GET_INSTANCE before using.public String normalizePath(String path)
FileUtilLimitednormalizePath in interface FileUtilLimitedpath - is the path to resolve.FileUtilLimited.normalizePath(String, char)public String normalizePath(String path, char separator)
FileUtilLimitedpath. It will resolve ".." and "." segments, normalize backslashes and
remove duplicated slashes. Further it can resolve "~" at the beginning of the path (like in bash-scripts, etc.).
Therefore this method resolves the path in such situations (e.g. to "/home/login/foo") and returns a physical path.
separator is '/' (backslashes are NOT escaped):
path |
normalizePath(path) |
|---|---|
"folder/subfolder//../.\some.file" |
"folder/some.file" |
"../.\some.file" |
"../some.file" |
"http://www.host.com/foo/bar/./test/.././.." |
"http://www.host.com/foo" |
"\\unc.host\printers\pr3761" |
"\\unc.host\printers\pr3761" |
"~/documents/index.html" |
home+ "/documents/index.html" |
"~root/subfolder/../folder/.//index.html" |
"/root/folder/index.html" |
normalizePath in interface FileUtilLimitedpath - is the path to resolve.separator - is the character to use as file separator.protected String normalizeHome(String path)
path - is the path where to normalize the home segment.protected String getUserHomeDirectoryPath()
protected String getUserLogin()
public String getExtension(String filename)
FileUtilLimitedfilename. getExtension("test.java") would return "java". filename is just a dot followed by the extension (e.g. ".java"), the empty string is
returned.getExtension in interface FileUtilLimitedfilename - is the filename and may include an absolute or relative path.filename excluding the dot in lowercase or
the empty string if NOT present.public String getBasename(String filename)
FileUtilLimitedfilename (path). The basename is the raw name of the
file without the path. | filename | getBasename(filename) |
|---|---|
| / | / |
| \/\ | \ |
| /. | . |
| /foo.bar | foo.bar |
| /foo/bar/ | bar |
| c:\\ | |
| c:\\foo | foo |
| http://foo.org/bar | bar |
getBasename in interface FileUtilLimitedfilename - is the path to a file or directory.filename.public String getDirname(String filename)
FileUtilLimitedfilename (path). | filename | FileUtilLimited.getDirname(String) |
|---|---|
| foo | . |
| /foo | / |
| /foo/bar | /foo |
| /foo/bar/ | /foo |
| ./foo/bar/ | ./foo |
| ./foo/bar/../ | ./foo/bar |
getDirname in interface FileUtilLimitedfilename - is the path to a file or directory.filename.FileUtilLimited.normalizePath(String)Copyright © 2001–2016 mmm-Team. All rights reserved.