Package org.apache.commons.io
Enum FileSystem
- All Implemented Interfaces:
- Serializable,- Comparable<FileSystem>
Abstracts an OS' file system details, currently supporting the single use case of converting a file name String to a
 legal file name with 
toLegalFileName(String, char).
 
 The starting point of any operation is getCurrent() which gets you the enum for the file system that matches
 the OS hosting the running JVM.
 
- Since:
- 2.7
- 
Enum Constant SummaryEnum Constants
- 
Method SummaryModifier and TypeMethodDescriptionintGets the file allocation block size in bytes.static FileSystemGets the current file system.char[]Gets a cloned copy of the illegal characters for this file system.int[]Gets a cloned copy of the illegal code points for this file system.intGets the maximum length for file names.intGets the maximum length of the path to a file.charGets the name separator, '\\' on Windows, '/' on Linux.String[]Gets a cloned copy of the reserved file names.booleanTests whether this file system preserves case.booleanTests whether this file system is case-sensitive.booleanisLegalFileName(CharSequence candidate) Tests if a candidate file name (without a path) such as"filename.ext"or"filename"is a potentially legal file name.booleanisReservedFileName(CharSequence candidate) Tests whether the given string is a reserved file name.normalizeSeparators(String path) Converts all separators to the Windows separator of backslash.booleanTests whether this file system support driver letters.toLegalFileName(String candidate, char replacement) Converts a candidate file name (without a path) like"filename.ext"or"filename"to a legal file name.static FileSystemReturns the enum constant of this type with the specified name.static FileSystem[]values()Returns an array containing the constants of this enum type, in the order they are declared.
- 
Enum Constant Details- 
GENERICGeneric file system.
- 
LINUXLinux file system.
- 
MAC_OSXMacOS file system.
- 
WINDOWSWindows file system.The reserved characters are defined in the Naming Conventions (microsoft.com). - See Also:
 
 
- 
- 
Method Details- 
valuesReturns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
 
- 
valueOfReturns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
- name- the name of the enum constant to be returned.
- Returns:
- the enum constant with the specified name
- Throws:
- IllegalArgumentException- if this enum type has no constant with the specified name
- NullPointerException- if the argument is null
 
- 
getCurrentGets the current file system.- Returns:
- the current file system
 
- 
getBlockSizeGets the file allocation block size in bytes.- Returns:
- the file allocation block size in bytes.
- Since:
- 2.12.0
 
- 
getIllegalFileNameCharsGets a cloned copy of the illegal characters for this file system.- Returns:
- the illegal characters for this file system.
 
- 
getIllegalFileNameCodePointsGets a cloned copy of the illegal code points for this file system.- Returns:
- the illegal code points for this file system.
- Since:
- 2.12.0
 
- 
getMaxFileNameLengthGets the maximum length for file names. The file name does not include folders.- Returns:
- the maximum length for file names.
 
- 
getMaxPathLengthGets the maximum length of the path to a file. This can include folders.- Returns:
- the maximum length of the path to a file.
 
- 
getNameSeparatorGets the name separator, '\\' on Windows, '/' on Linux.- Returns:
- '\\' on Windows, '/' on Linux.
- Since:
- 2.12.0
 
- 
getReservedFileNamesGets a cloned copy of the reserved file names.- Returns:
- the reserved file names.
 
- 
isCasePreservingTests whether this file system preserves case.- Returns:
- Whether this file system preserves case.
 
- 
isCaseSensitiveTests whether this file system is case-sensitive.- Returns:
- Whether this file system is case-sensitive.
 
- 
isLegalFileNameTests if a candidate file name (without a path) such as"filename.ext"or"filename"is a potentially legal file name. If the file name length exceedsgetMaxFileNameLength(), or if it contains an illegal character then the check fails.- Parameters:
- candidate- a candidate file name (without a path) like- "filename.ext"or- "filename"
- Returns:
- trueif the candidate name is legal
 
- 
isReservedFileNameTests whether the given string is a reserved file name.- Parameters:
- candidate- the string to test
- Returns:
- trueif the given string is a reserved file name.
 
- 
normalizeSeparatorsConverts all separators to the Windows separator of backslash.- Parameters:
- path- the path to be changed, null ignored
- Returns:
- the updated path
- Since:
- 2.12.0
 
- 
supportsDriveLetterTests whether this file system support driver letters.Windows supports driver letters as do other operating systems. Whether these other OS's still support Java like OS/2, is a different matter. - Returns:
- whether this file system support driver letters.
- Since:
- 2.9.0
- See Also:
 
- 
toLegalFileNameConverts a candidate file name (without a path) like"filename.ext"or"filename"to a legal file name. Illegal characters in the candidate name are replaced by thereplacementcharacter. If the file name length exceedsgetMaxFileNameLength(), then the name is truncated togetMaxFileNameLength().- Parameters:
- candidate- a candidate file name (without a path) like- "filename.ext"or- "filename"
- replacement- Illegal characters in the candidate name are replaced by this character
- Returns:
- a String without illegal characters
 
 
-