?? IOCase
- ????????:
Serializable
,Comparable<IOCase>
,java.lang.constant.Constable
Different filing systems have different rules for case-sensitivity. Windows is case-insensitive, Unix is case-sensitive.
This class captures that difference, providing an enumeration to control how file name comparisons should be performed. It also provides methods that use the enumeration to perform comparisons.
Wherever possible, you should use the check
methods in this
class to compare file names.
- ???????:
- 1.3
-
?????
????????/?? java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
??????
??????????The constant for case insensitive regardless of operating system.The constant for case sensitive regardless of operating system.The constant for case sensitivity determined by the current operating system. -
????
??????????int
checkCompareTo
(String str1, String str2) Compares two strings using the case-sensitivity rule.boolean
checkEndsWith
(String str, String end) Checks if one string ends with another using the case-sensitivity rule.boolean
checkEquals
(String str1, String str2) Compares two strings using the case-sensitivity rule.int
checkIndexOf
(String str, int strStartIndex, String search) Checks if one string contains another starting at a specific index using the case-sensitivity rule.boolean
checkRegionMatches
(String str, int strStartIndex, String search) Checks if one string contains another at a specific index using the case-sensitivity rule.boolean
checkStartsWith
(String str, String start) Checks if one string starts with another using the case-sensitivity rule.static IOCase
Factory method to create an IOCase from a name.getName()
Gets the name of the constant.boolean
Does the object represent case sensitive comparison.static boolean
isCaseSensitive
(IOCase caseSensitivity) Tests for cases sensitivity in a null-safe manner.toString()
Gets a string describing the sensitivity.static IOCase
?????????????????? ??????????????????? ????????(?????? ??????)static IOCase[]
values()
???????????????, ??????????????
-
????????
-
SENSITIVE
The constant for case sensitive regardless of operating system. -
INSENSITIVE
The constant for case insensitive regardless of operating system. -
SYSTEM
The constant for case sensitivity determined by the current operating system. Windows is case-insensitive when comparing file names, Unix is case-sensitive.Note: This only caters for Windows and Unix. Other operating systems (e.g. OSX and OpenVMS) are treated as case sensitive if they use the Unix file separator and case-insensitive if they use the Windows file separator (see
File.separatorChar
).If you serialize this constant on Windows, and deserialize on Unix, or vice versa, then the value of the case-sensitivity flag will change.
-
-
??????
-
values
???????????????, ??????????????- ??:
- ???????????????????????????
-
valueOf
?????????????????? ??????????????????? ????????(?????? ??????)- ??:
name
- ????????????- ??:
- ?????????????
- ??:
IllegalArgumentException
- ??????????????????NullPointerException
- ???????
-
isCaseSensitive
Tests for cases sensitivity in a null-safe manner.- ??:
caseSensitivity
- an IOCase.- ??:
- true if the input is non-null and
isCaseSensitive()
. - ???????:
- 2.10.0
-
forName
Factory method to create an IOCase from a name.- ??:
name
- the name to find- ??:
- the IOCase object
- ??:
IllegalArgumentException
- if the name is invalid
-
getName
Gets the name of the constant.- ??:
- the name of the constant
-
isCaseSensitive
Does the object represent case sensitive comparison.- ??:
- true if case sensitive
-
checkCompareTo
Compares two strings using the case-sensitivity rule.This method mimics
String.compareTo(java.lang.String)
but takes case-sensitivity into account.- ??:
str1
- the first string to compare, not nullstr2
- the second string to compare, not null- ??:
- true if equal using the case rules
- ??:
NullPointerException
- if either string is null
-
checkEquals
Compares two strings using the case-sensitivity rule.This method mimics
String.equals(java.lang.Object)
but takes case-sensitivity into account.- ??:
str1
- the first string to compare, not nullstr2
- the second string to compare, not null- ??:
- true if equal using the case rules
- ??:
NullPointerException
- if either string is null
-
checkStartsWith
Checks if one string starts with another using the case-sensitivity rule.This method mimics
String.startsWith(String)
but takes case-sensitivity into account.- ??:
str
- the string to checkstart
- the start to compare against- ??:
- true if equal using the case rules, false if either input is null
-
checkEndsWith
Checks if one string ends with another using the case-sensitivity rule.This method mimics
String.endsWith(java.lang.String)
but takes case-sensitivity into account.- ??:
str
- the string to checkend
- the end to compare against- ??:
- true if equal using the case rules, false if either input is null
-
checkIndexOf
Checks if one string contains another starting at a specific index using the case-sensitivity rule.This method mimics parts of
String.indexOf(String, int)
but takes case-sensitivity into account.- ??:
str
- the string to check, not nullstrStartIndex
- the index to start at in strsearch
- the start to search for, not null- ??:
- the first index of the search String,
-1 if no match or
null
string input - ??:
NullPointerException
- if either string is null- ???????:
- 2.0
-
checkRegionMatches
Checks if one string contains another at a specific index using the case-sensitivity rule.This method mimics parts of
String.regionMatches(boolean, int, String, int, int)
but takes case-sensitivity into account.- ??:
str
- the string to check, not nullstrStartIndex
- the index to start at in strsearch
- the start to search for, not null- ??:
- true if equal using the case rules
- ??:
NullPointerException
- if either string is null
-
toString
Gets a string describing the sensitivity.
-