パッケージ com.kazurayam.ant.util
クラス FileUtils
- java.lang.Object
-
- com.kazurayam.ant.util.FileUtils
-
public class FileUtils extends java.lang.Object
-
-
コンストラクタの概要
コンストラクタ 修飾子 コンストラクタ 説明 protected
FileUtils()
Empty constructor.
-
メソッドの概要
すべてのメソッド staticメソッド インスタンス・メソッド concreteメソッド 修飾子とタイプ メソッド 説明 java.lang.String[]
dissect(java.lang.String path)
Dissect the specified absolute path.java.lang.String
fromURI(java.lang.String uri)
Constructs a file path from afile:
URI.static FileUtils
getFileUtils()
Method to retrieve The FileUtils, which is shared by all users of this method.static boolean
isAbsolutePath(java.lang.String filename)
Verifies that the specified filename represents an absolute path.static boolean
isContextRelativePath(java.lang.String filename)
On DOS and NetWare, the evaluation of certain file specifications is context-dependent.java.io.File
normalize(java.lang.String path)
"Normalize" the given absolute path.java.lang.String
removeLeadingPath(java.io.File leading, java.io.File path)
Removes a leading path from a second path.java.io.File
resolveFile(java.io.File file, java.lang.String filename)
Interpret the filename as a file relative to the given file unless the filename already represents an absolute filename.
-
-
-
メソッドの詳細
-
getFileUtils
public static FileUtils getFileUtils()
Method to retrieve The FileUtils, which is shared by all users of this method.- 戻り値:
- an instance of FileUtils.
- 導入されたバージョン:
- Ant 1.6.3
-
isAbsolutePath
public static boolean isAbsolutePath(java.lang.String filename)
Verifies that the specified filename represents an absolute path. Differs from new java.io.File("filename").isAbsolute() in that a path beginning with a double file separator--signifying a Windows UNC--must at minimum match "\\a\b" to be considered an absolute path.- パラメータ:
filename
- the filename to be checked.- 戻り値:
- true if the filename represents an absolute path.
- 例外:
java.lang.NullPointerException
- if filename is null.- 導入されたバージョン:
- Ant 1.6.3
-
fromURI
public java.lang.String fromURI(java.lang.String uri)
Constructs a file path from afile:
URI.Will be an absolute path if the given URI is absolute.
Swallows '%' that are not followed by two characters, doesn't deal with non-ASCII characters.
- パラメータ:
uri
- the URI designating a file in the local filesystem.- 戻り値:
- the local file system path for the file.
- 導入されたバージョン:
- Ant 1.6
-
normalize
public java.io.File normalize(java.lang.String path)
"Normalize" the given absolute path.This includes:
- Uppercase the drive letter if there is one.
- Remove redundant slashes after the drive spec.
- Resolve all ./, .\, ../ and ..\ sequences.
- DOS style paths that start with a drive letter will have \ as the separator.
Unlike
File.getCanonicalPath()
this method specifically does not resolve symbolic links.If the path tries to go beyond the file system root (i.e. it contains more ".." segments than can be travelled up) the method will return the original path unchanged.
- パラメータ:
path
- the path to be normalized.- 戻り値:
- the normalized version of the path.
- 例外:
java.lang.NullPointerException
- if path is null.
-
dissect
public java.lang.String[] dissect(java.lang.String path)
Dissect the specified absolute path.- パラメータ:
path
- the path to dissect.- 戻り値:
- String[] {root, remaining path}.
- 例外:
java.lang.NullPointerException
- if path is null.- 導入されたバージョン:
- Ant 1.7
-
removeLeadingPath
public java.lang.String removeLeadingPath(java.io.File leading, java.io.File path)
Removes a leading path from a second path.This method uses
normalize(java.lang.String)
under the covers and does not resolve symbolic links.- パラメータ:
leading
- The leading path, must not be null, must be absolute.path
- The path to remove from, must not be null, must be absolute.- 戻り値:
- path's normalized absolute if it doesn't start with leading; path's path with leading's path removed otherwise.
- 導入されたバージョン:
- Ant 1.5
-
resolveFile
public java.io.File resolveFile(java.io.File file, java.lang.String filename)
Interpret the filename as a file relative to the given file unless the filename already represents an absolute filename. Differs fromnew File(file, filename)
in that the resulting File's path will always be a normalized, absolute pathname. Also, if it is determined thatfilename
is context-relative,file
will be discarded and the reference will be resolved using available context/state information about the filesystem.- パラメータ:
file
- the "reference" file for relative paths. This instance must be an absolute file and must not contain "./" or "../" sequences (same for \ instead of /). If it is null, this call is equivalent tonew java.io.File(filename).getAbsoluteFile()
.filename
- a file name.- 戻り値:
- an absolute file.
- 例外:
java.lang.NullPointerException
- if filename is null.
-
isContextRelativePath
public static boolean isContextRelativePath(java.lang.String filename)
On DOS and NetWare, the evaluation of certain file specifications is context-dependent. These are filenames beginning with a single separator (relative to current root directory) and filenames with a drive specification and no intervening separator (relative to current directory of the specified root).- パラメータ:
filename
- the filename to evaluate.- 戻り値:
- true if the filename is relative to system context.
- 例外:
java.lang.NullPointerException
- if filename is null.- 導入されたバージョン:
- Ant 1.7
-
-