public final class PathTools
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
PathTools.PathParts |
Modifier | Constructor and Description |
---|---|
private |
PathTools() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
addSlash(java.lang.String path) |
static java.lang.String |
getBaseName(java.lang.String fullName)
Gets the base name of the file -- i.e.
|
static java.lang.String |
getBaseName(java.lang.String fullName,
boolean allowMultiDotExtensions)
Gets the base name of the file -- i.e.
|
static java.lang.String |
getExt(java.lang.String fullName)
Gets the extension of the file including the preceding dot (.)
If the file name contains multiple dot (.) characters, the extension is defined as the segment starting with
the final dot.
|
static java.lang.String |
getExt(java.lang.String fullName,
boolean allowMultiDotExtensions)
Gets the extension of the file including the preceding dot (.)
|
static PathTools.PathParts |
getParts(java.lang.String fullFilePath) |
static PathTools.PathParts |
getParts(java.lang.String fullFilePath,
boolean splitDirs) |
static PathTools.PathParts |
getParts(java.lang.String fullFilePath,
boolean splitDirs,
boolean allowMultiDotExtensions) |
static java.lang.String |
getPath(java.lang.String fullName)
Get the full parent directory path, including the final slash.
|
public static java.lang.String addSlash(java.lang.String path)
public static java.lang.String getBaseName(java.lang.String fullName)
fullName
- The full file name or path.getBaseName(String, boolean)
public static java.lang.String getBaseName(java.lang.String fullName, boolean allowMultiDotExtensions)
fullName
- The full file name or path.allowMultiDotExtensions
- If true, the extension starts at the first dot (.) encountered, which
means the resulting base name will never contain any dots.
If false, the extension starts at the last dot, so the base name will
contain all dots except the final one.public static java.lang.String getExt(java.lang.String fullName)
fullName
- The full file name or path.public static java.lang.String getExt(java.lang.String fullName, boolean allowMultiDotExtensions)
fullName
- The full file name or path.allowMultiDotExtensions
- If true, the extension starts at the first dot (.) encountered in
the file name, which means the resulting extension may contain more than one dot.
If false, the extension starts at the last dot, so the extension will
either be empty (if the file has no extension) or it will contain exactly one
dot as its first character.public static PathTools.PathParts getParts(java.lang.String fullFilePath)
public static PathTools.PathParts getParts(java.lang.String fullFilePath, boolean splitDirs)
public static PathTools.PathParts getParts(java.lang.String fullFilePath, boolean splitDirs, boolean allowMultiDotExtensions)
public static java.lang.String getPath(java.lang.String fullName)
/path/to/fileName.ext | --> | /path/to/ |
/fileName.ext | --> | / |
C:\Windows\System32 | --> | C:\Windows\ |
images\banana.jpg | --> | images\ |
HelloWorld.txt | --> | (empty) |
fullName
- The full path to the file.\
or /
.