|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.lucidviews.util.io.FilePaths
public class FilePaths
A collection of methods for manipualting paths to files and folders.
Field Summary | |
---|---|
static Map<Character,Character> |
SPECIAL_CHARACTER_REPLACEMENTS
A default mapping of special characters to alternative, non-special characters. |
static String |
SPECIAL_CHARACTERS
The special characters that are reserved for file system paths in the operating system that is running this program. |
protected static Map<String,String> |
SPECIAL_CHARACTERS_BY_OS
A lookup table of special characters that are reserved for file system paths, indexed by the name of the operating system to which the reserved characters apply. |
Constructor Summary | |
---|---|
protected |
FilePaths()
The default constructor. |
Method Summary | |
---|---|
static String |
getSpecialChars()
Get the special (reserved) characters for file system paths for the operating system that is running this program. |
static String |
getSpecialChars(String osName)
Get the special (reserved) characters for file system paths for a given operating system. |
static boolean |
isSamePath(File file1,
File file2)
Check if two files point to the same location. |
static String |
validateFileName(String fileName)
Create a valid name for a file, either replacing any illegal (reserved) characters in the original name with the default replacement characters or removing the illegal characters entirely. |
static String |
validateFileName(String fileName,
Map<Character,Character> replacementCharacters)
Create a valid name for a file, either replacing any illegal (reserved) characters in the original name with the suggested replacement characters or removing the illegal characters entirely. |
static File |
validateFilePath(File file)
Create a valid file path, either replacing any illegal (reserved) characters in the original path with the default replacement characters or removing the illegal characters entirely. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Map<String,String> SPECIAL_CHARACTERS_BY_OS
public static final String SPECIAL_CHARACTERS
public static final Map<Character,Character> SPECIAL_CHARACTER_REPLACEMENTS
Constructor Detail |
---|
protected FilePaths()
Method Detail |
---|
public static final boolean isSamePath(File file1, File file2) throws IOException
file1
- the first filefile2
- the other file
true
if the two File
s reference the same location
IOException
- if the file paths cannot be resolved into canonical formpublic static File validateFilePath(File file)
file
- the original file path
SPECIAL_CHARACTER_REPLACEMENTS
public static String validateFileName(String fileName)
fileName
- the original file name
SPECIAL_CHARACTER_REPLACEMENTS
public static String validateFileName(String fileName, Map<Character,Character> replacementCharacters)
fileName
- the original file namereplacementCharacters
- characters used to replace illegal characters
public static String getSpecialChars()
public static String getSpecialChars(String osName) throws UnsupportedOperationException
osName
- the name of the operating system
(version is optional, e.g. "Windows" or "Windows XP" will both find the settings for Windows)
UnsupportedOperationException
- if the operating system is unknown (not supported)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |