?? FileSystem
- ????????:
Serializable
,Comparable<FileSystem>
,java.lang.constant.Constable
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.
- ???????:
- 2.7
-
?????
????????/?? java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
??????
???? -
????
??????????static FileSystem
Gets the current file system.char[]
Gets a cloned copy of the illegal characters for this file system.int
Gets the maximum length for file names.int
Gets the maximum length of the path to a file.String[]
Gets a cloned copy of the reserved file names.boolean
Whether this file system preserves case.boolean
Whether this file system is case-sensitive.boolean
isLegalFileName
(CharSequence candidate) Checks if a candidate file name (without a path) such as"filename.ext"
or"filename"
is a potentially legal file name.boolean
isReservedFileName
(CharSequence candidate) Returns whether the given string is a reserved file name.boolean
Tests 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 FileSystem
?????????????????? ??????????????????? ????????(?????? ??????)static FileSystem[]
values()
???????????????, ??????????????
-
????????
-
GENERIC
Generic file system. -
LINUX
Linux file system. -
MAC_OSX
MacOS file system. -
WINDOWS
Windows file system.The reserved characters are defined in the Naming Conventions (microsoft.com).
-
-
??????
-
values
???????????????, ??????????????- ??:
- ???????????????????????????
-
valueOf
?????????????????? ??????????????????? ????????(?????? ??????)- ??:
name
- ????????????- ??:
- ?????????????
- ??:
IllegalArgumentException
- ??????????????????NullPointerException
- ???????
-
getCurrent
Gets the current file system.- ??:
- the current file system
-
getIllegalFileNameChars
Gets a cloned copy of the illegal characters for this file system.- ??:
- the illegal characters for this file system.
-
getMaxFileNameLength
Gets the maximum length for file names. The file name does not include folders.- ??:
- the maximum length for file names.
-
getMaxPathLength
Gets the maximum length of the path to a file. This can include folders.- ??:
- the maximum length of the path to a file.
-
getReservedFileNames
Gets a cloned copy of the reserved file names.- ??:
- the reserved file names.
-
isCasePreserving
Whether this file system preserves case.- ??:
- Whether this file system preserves case.
-
isCaseSensitive
Whether this file system is case-sensitive.- ??:
- Whether this file system is case-sensitive.
-
isLegalFileName
Checks 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.- ??:
candidate
- a candidate file name (without a path) like"filename.ext"
or"filename"
- ??:
true
if the candidate name is legal
-
isReservedFileName
Returns whether the given string is a reserved file name.- ??:
candidate
- the string to test- ??:
true
if the given string is a reserved file name.
-
supportsDriveLetter
Tests 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.
- ??:
- whether this file system support driver letters.
- ???????:
- 2.9.0
- ????:
-
toLegalFileName
Converts 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 thereplacement
character. If the file name length exceedsgetMaxFileNameLength()
, then the name is truncated togetMaxFileNameLength()
.- ??:
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- ??:
- a String without illegal characters
-