public class PathUtilRt
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
PathUtilRt.Platform |
Constructor and Description |
---|
PathUtilRt() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getFileExtension(java.lang.String path) |
static java.lang.String |
getFileName(java.lang.String path) |
static java.lang.String |
getParentPath(java.lang.String path) |
static boolean |
isValidFileName(java.lang.String fileName,
boolean strict)
Checks whether a file with the given name can be created on a current platform.
|
static boolean |
isValidFileName(java.lang.String name,
PathUtilRt.Platform os,
boolean strict,
java.nio.charset.Charset cs)
Checks whether a file with the given name can be created on a platform specified by given parameters.
|
static java.lang.String |
suggestFileName(java.lang.String text) |
static java.lang.String |
suggestFileName(java.lang.String text,
boolean allowDots,
boolean allowSpaces) |
public static java.lang.String getFileName(java.lang.String path)
public static java.lang.String getFileExtension(java.lang.String path)
public static java.lang.String getParentPath(java.lang.String path)
public static java.lang.String suggestFileName(java.lang.String text)
public static java.lang.String suggestFileName(java.lang.String text, boolean allowDots, boolean allowSpaces)
public static boolean isValidFileName(java.lang.String fileName, boolean strict)
public static boolean isValidFileName(java.lang.String name, PathUtilRt.Platform os, boolean strict, java.nio.charset.Charset cs)
Platform restrictions:
Platform.UNIX
prohibits empty names, traversals (".", ".."), and names containing '/' or '\' characters.
Platform.WINDOWS
prohibits empty names, traversals (".", ".."), reserved names ("CON", "NUL", "COM1" etc.),
and names containing any of characters <>:"/\|?*
or control characters (range 0..31)
(more info).
os
- specifies a platform.strict
- prohibits names containing any of characters <>:"/\|?*;
and control characters (range 0..31).cs
- prohibits names which cannot be encoded by this charset (optional).