@ComponentSpecification public interface FileUtilLimited
File
handling and manipulation. Files
that offers similar and additional features. However this is
not supported in limited environments such as e.g. GWT.FileUtilLimitedImpl
Modifier and Type | Field and Description |
---|---|
static File[] |
NO_FILES
An empty file array.
|
static String |
PATH_SEGMENT_CURRENT
The path segment indicating the current folder itself.
|
static String |
PATH_SEGMENT_PARENT
The path segment indicating the parent folder.
|
static String |
PROPERTY_TMP_DIR
The key of the
system property "java.io.tmpdir". |
static String |
PROPERTY_USER_HOME
The key of the
system property "user.home". |
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 . |
String |
normalizePath(String path)
|
String |
normalizePath(String path,
char separator)
This method normalizes a given
path . |
static final String PATH_SEGMENT_CURRENT
static final String PATH_SEGMENT_PARENT
static final String PROPERTY_USER_HOME
system property
"user.home". It contains the home directory of the
user that started this JVM. /home/mylogin
or C:\Windows\Profiles\mylogin
.static final String PROPERTY_TMP_DIR
system property
"java.io.tmpdir". It contains the directory to use for
temporary files. /tmp
, C:\Temp
or /usr/local/tomcat/temp
.static final File[] NO_FILES
String normalizePath(String path, char separator)
path
. 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" |
path
- is the path to resolve.separator
- is the character to use as file separator
.String normalizePath(String path)
path
- is the path to resolve.normalizePath(String, char)
String getExtension(String filename)
filename
. getExtension
("test.java")
would return "java"
. filename
is just a dot followed by the extension (e.g. ".java"
), the empty string is
returned.filename
- is the filename and may include an absolute or relative path.filename
excluding the dot in lowercase
or
the empty string if NOT present.String getBasename(String filename)
filename
(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 |
filename
- is the path to a file or directory.filename
.String getDirname(String filename)
filename
(path). filename | getDirname(String) |
---|---|
foo | . |
/foo | / |
/foo/bar | /foo |
/foo/bar/ | /foo |
./foo/bar/ | ./foo |
./foo/bar/../ | ./foo/bar |
filename
- is the path to a file or directory.filename
.normalizePath(String)
Copyright © 2001–2016 mmm-Team. All rights reserved.