public final class FilePathUtils extends Object
Constructor and Description |
---|
FilePathUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
addSeparator(String path,
char fps)
Return the path with the specified file separator added at the end, or
the original path if it already has a trailing path separator.
|
static String |
childPath(String parentPath,
String path,
char fps)
Return the next child path segment given the model path and base parent
path.
|
static String |
combinePath(String path,
String name,
char fps)
Return the path that results when the child name is catenated to the
parent path and separated using the given file path separator.
|
static String |
drive(String path)
Return the drive designation extracted from the specified path.
|
static String |
extension(String name)
Return the extension of the given file leaf name, i.e.
|
static String |
extension(String name,
char fps)
Return the extension of the given file name, i.e.
|
static String |
filename(String path,
char fps)
Returns the full name of the file only, without the directory path
information
|
static String |
fullPath(String path)
Return the full path stripped of the mount-point drive letter.
|
static String |
leafName(String path,
char fps)
Return the leaf name (aka basename) segment of the path.
|
static String |
mountPoint(String path,
char fps)
Return the mount point portion of the specified path, i.e.
|
static String |
normalizedPath(String path)
Return the specified path with all backward slash separators replaced by
forward slash separators.
|
static String |
normalizedPath(String path,
boolean isDir)
Return the specified path with all backward slash separators replaced by
forward slash separators.
|
static String |
parentPath(String path,
char fps)
Return the parent path of the specified path.
|
static String |
prefixFilename(String path,
char fps)
Returns the name of the file without the extension
|
static String |
relativePath(String parentPath,
String path,
char fps)
Return the relative path using the supplied parent path.
|
static String |
sansExtension(String name,
char fps)
Return the path sans the extension of the given file leaf name, i.e.
|
static String |
tmp()
Get the path to the system temporary directory.
|
static String |
trimSeparator(String path,
char fps)
Return the path with the specified file separator trimmed from the end,
or the original path if it already lacks a trailing path separator.
|
public static String tmp()
public static String normalizedPath(String path, boolean isDir)
path
- path to be normalizedisDir
- boolean indicating that the path is that of a directorypublic static String normalizedPath(String path)
path
- path to be normalizedpublic static String parentPath(String path, char fps)
path
- path from which to extract the parent pathfps
- character representing the file path separatorpublic static String relativePath(String parentPath, String path, char fps)
parentPath
- parent path to which the path is relative; this path
is assumed to be normalizedpath
- normalized path to be made relativefps
- character representing the file path separatorpublic static String leafName(String path, char fps)
path
- path from which to extract the leaf namefps
- character representing the file path separatorpublic static String childPath(String parentPath, String path, char fps)
parentPath
- parent path to use as a basepath
- model path from which to extract the next child using the
parent pathfps
- character representing the file path separatorpublic static String addSeparator(String path, char fps)
path
- path to which the separator should be addedfps
- file path separator to use if needed, which is if the parent
path already does not end with a trailing path separatorpublic static String trimSeparator(String path, char fps)
path
- path from which the separator should be trimedfps
- file path separator to use if needed, which is if the path
ends with a trailing path separatorpublic static String combinePath(String path, String name, char fps)
path
- parent path to use as the first part of the resultname
- child name to append to the parent pathfps
- file path separator to use if needed, which is if the path
already does not end with a trailing path separatorpublic static String mountPoint(String path, char fps)
path
- file path from which to extract the mount-pointfps
- file path separator to use for extraction of mount pointpublic static String fullPath(String path)
path
- path from which to strip-off drive letter portion.public static String drive(String path)
path
- path from which to extract drive informationpublic static String sansExtension(String name, char fps)
Assumes a leaf file name is supplied. Returns an empty string if there is no extension found.
name
- file name from which to extract the extensionfps
- file path separatorpublic static String extension(String name, char fps)
Returns an empty string if there is no extension found.
name
- file name from which to extract the extensionfps
- file path separatorpublic static String extension(String name)
Assumes a leaf file name is supplied. Returns an empty string if there is no extension found.
name
- file name from which to extract the extensionpublic static String prefixFilename(String path, char fps)
path
- full name of the file or pathfps
- file path separatorCopyright © 2015. All Rights Reserved.