Package com.atlassian.bamboo.file
Class SafeFileTools
java.lang.Object
com.atlassian.bamboo.file.SafeFileTools
A set of static methods that fives access to secure operations on file without returning the
File object.- Since:
- 12.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanTests whether the file denoted by this abstract pathname is readable.static booleanTests whether the file denoted by this abstract pathname is writable.static booleanTests whether the file denoted by this abstract pathname exists.static StringgetCanonicalPath(String path) Returns the canonical path of the file.static StringgetParentPath(String path) Returns the parent path of the file.static booleanTests whether the file denoted by this abstract pathname has a parent.static booleanisAbsolute(String path) Tests if this abstract pathname is absolute.static booleanisDirectory(String path) Tests whether the file denoted by this abstract pathname is a directory.static booleanTests whether the file denoted by this abstract pathname is a regular file.
-
Constructor Details
-
SafeFileTools
public SafeFileTools()
-
-
Method Details
-
getCanonicalPath
Returns the canonical path of the file. This method wraps a call toFile.getCanonicalPath()so that all file operations are in this class.- Parameters:
path- the file to get the canonical path for- Returns:
- the canonical path of the file
- Throws:
IOException
-
isAbsolute
Tests if this abstract pathname is absolute. This method wraps a call toFile.isAbsolute()so that all file operations are in this class.- Parameters:
path- the file to test- Returns:
trueif this abstract pathname is absolute,falseotherwise
-
isDirectory
Tests whether the file denoted by this abstract pathname is a directory. This method wraps a call toFile.isDirectory()so that all file operations are in this class.- Parameters:
path- the file to test- Returns:
trueif and only if the file denoted by this abstract pathname exists and is a directory;falseotherwise
-
exists
Tests whether the file denoted by this abstract pathname exists. This method wraps a call toFile.exists()so that all file operations are in this class.- Parameters:
path- the file to test- Returns:
trueif and only if the file denoted by this abstract pathname exists;falseotherwise
-
canWrite
Tests whether the file denoted by this abstract pathname is writable. This method wraps a call toFile.canWrite()so that all file operations are in this class.- Parameters:
path- the file to test- Returns:
trueif and only if the file denoted by this abstract pathname exists and is writable;falseotherwise
-
canRead
Tests whether the file denoted by this abstract pathname is readable. This method wraps a call toFile.canRead()so that all file operations are in this class.- Parameters:
path- the file to test- Returns:
trueif and only if the file denoted by this abstract pathname exists and is readable;falseotherwise
-
isFile
Tests whether the file denoted by this abstract pathname is a regular file. This method wraps a call toFile.isFile()so that all file operations are in this class.- Parameters:
path- the file to test- Returns:
trueif and only if the file denoted by this abstract pathname exists and is a regular file;falseotherwise
-
hasParent
Tests whether the file denoted by this abstract pathname has a parent. This method wraps a call toFile.getParent()so that all file operations are in this class. Examples:- /path/to/file.txt -> true - /path/to/ -> true - /path/to -> true - /path/to/file.txt/ -> true - /file.txt -> true - /path/ -> true - path/file.txt -> true - ./file.txt -> true - / -> false - file.txt -> false
- Parameters:
path- the file to test- Returns:
trueif and only if the file denoted by this abstract pathname has a parent;falseotherwise
-
getParentPath
Returns the parent path of the file. This method wraps a call toFile.getParentFile()so that all file operations are in this class.- Parameters:
path- the file to get the parent path for- Returns:
- the parent path of the file
-