public class CharUtil extends Object
Modifier and Type | Field and Description |
---|---|
static char |
AMP
字符常量:与
'&' |
static char |
AT
字符常量:艾特
'@' |
static char |
BACKSLASH
字符常量:反斜杠
'\\' |
static char |
BRACKET_END
字符常量:中括号(右)
']' |
static char |
BRACKET_START
字符常量:中括号(左)
'[' |
static char |
COLON
字符常量:冒号
':' |
static char |
COMMA
字符常量:逗号
',' |
static char |
CR
字符常量:回车符
'\r' |
static char |
DASHED
字符常量:减号(连接符)
'-' |
static char |
DELIM_END
字符常量:花括号(右)
'}' |
static char |
DELIM_START
字符常量:花括号(左)
'{' |
static char |
DOT
字符常量:点
'.' |
static char |
DOUBLE_QUOTES
字符常量:双引号
'"' |
static char |
LF
字符常量:换行符
'\n' |
static char |
SINGLE_QUOTE
字符常量:单引号
'\'' |
static char |
SLASH
字符常量:斜杠
'/' |
static char |
SPACE
字符常量:空格符
' ' |
static char |
TAB
字符常量:制表符
'\t' |
static char |
UNDERLINE
字符常量:下划线
'_' |
Constructor and Description |
---|
CharUtil() |
Modifier and Type | Method and Description |
---|---|
static int |
digit16(int b)
获取给定字符的16进制数值
|
static boolean |
equals(char c1,
char c2,
boolean ignoreCase)
比较两个字符是否相同
|
static int |
getType(int c)
获取字符类型
|
static boolean |
isAscii(char ch)
是否为ASCII字符,ASCII字符位于0~127之间
|
static boolean |
isAsciiControl(char ch)
是否为ASCII控制符(不可见字符),控制符位于0~31和127
|
static boolean |
isAsciiPrintable(char ch)
是否为可见ASCII字符,可见字符位于32~126之间
|
static boolean |
isBlankChar(char c)
是否空白符
空白符包括空格、制表符、全角空格和不间断空格 |
static boolean |
isBlankChar(int c)
是否空白符
空白符包括空格、制表符、全角空格和不间断空格 |
static boolean |
isChar(Object value)
给定对象对应的类是否为字符类,字符类包括:
|
static boolean |
isCharClass(Class<?> clazz)
给定类名是否为字符类,字符类包括:
|
static boolean |
isEmoji(char c)
判断是否为emoji表情符
|
static boolean |
isFileSeparator(char c)
是否为Windows或者Linux(Unix)文件分隔符
Windows平台下分隔符为\,Linux(Unix)为/ |
static boolean |
isHexChar(char c)
是否为16进制规范的字符,判断是否为如下字符
|
static boolean |
isLetter(char ch)
判断是否为字母(包括大写字母和小写字母)
字母包括A~Z和a~z |
static boolean |
isLetterLower(char ch)
检查字符是否为小写字母,小写字母指a~z
|
static boolean |
isLetterOrNumber(char ch)
是否为字母或数字,包括A~Z、a~z、0~9
|
static boolean |
isLetterUpper(char ch)
判断是否为大写字母,大写字母包括A~Z
|
static boolean |
isNumber(char ch)
检查是否为数字字符,数字字符指0~9
|
static String |
toString(char c)
字符转为字符串
如果为ASCII字符,使用缓存 |
public static final char SPACE
' '
public static final char TAB
'\t'
public static final char DOT
'.'
public static final char SLASH
'/'
public static final char BACKSLASH
'\\'
public static final char CR
'\r'
public static final char LF
'\n'
public static final char DASHED
'-'
public static final char UNDERLINE
'_'
public static final char COMMA
','
public static final char DELIM_START
'{'
public static final char DELIM_END
'}'
public static final char BRACKET_START
'['
public static final char BRACKET_END
']'
public static final char DOUBLE_QUOTES
'"'
public static final char SINGLE_QUOTE
'\''
public static final char AMP
'&'
public static final char COLON
':'
public static final char AT
'@'
public static boolean isAscii(char ch)
CharUtil.isAscii('a') = true CharUtil.isAscii('A') = true CharUtil.isAscii('3') = true CharUtil.isAscii('-') = true CharUtil.isAscii('\n') = true CharUtil.isAscii('©') = false
ch
- 被检查的字符处public static boolean isAsciiPrintable(char ch)
CharUtil.isAsciiPrintable('a') = true CharUtil.isAsciiPrintable('A') = true CharUtil.isAsciiPrintable('3') = true CharUtil.isAsciiPrintable('-') = true CharUtil.isAsciiPrintable('\n') = false CharUtil.isAsciiPrintable('©') = false
ch
- 被检查的字符处public static boolean isAsciiControl(char ch)
CharUtil.isAsciiControl('a') = false CharUtil.isAsciiControl('A') = false CharUtil.isAsciiControl('3') = false CharUtil.isAsciiControl('-') = false CharUtil.isAsciiControl('\n') = true CharUtil.isAsciiControl('©') = false
ch
- 被检查的字符public static boolean isLetter(char ch)
CharUtil.isLetter('a') = true CharUtil.isLetter('A') = true CharUtil.isLetter('3') = false CharUtil.isLetter('-') = false CharUtil.isLetter('\n') = false CharUtil.isLetter('©') = false
ch
- 被检查的字符public static boolean isLetterUpper(char ch)
判断是否为大写字母,大写字母包括A~Z
CharUtil.isLetterUpper('a') = false CharUtil.isLetterUpper('A') = true CharUtil.isLetterUpper('3') = false CharUtil.isLetterUpper('-') = false CharUtil.isLetterUpper('\n') = false CharUtil.isLetterUpper('©') = false
ch
- 被检查的字符public static boolean isLetterLower(char ch)
检查字符是否为小写字母,小写字母指a~z
CharUtil.isLetterLower('a') = true CharUtil.isLetterLower('A') = false CharUtil.isLetterLower('3') = false CharUtil.isLetterLower('-') = false CharUtil.isLetterLower('\n') = false CharUtil.isLetterLower('©') = false
ch
- 被检查的字符public static boolean isNumber(char ch)
检查是否为数字字符,数字字符指0~9
CharUtil.isNumber('a') = false CharUtil.isNumber('A') = false CharUtil.isNumber('3') = true CharUtil.isNumber('-') = false CharUtil.isNumber('\n') = false CharUtil.isNumber('©') = false
ch
- 被检查的字符public static boolean isHexChar(char c)
1. 0~9 2. a~f 4. A~F
c
- 字符public static boolean isLetterOrNumber(char ch)
CharUtil.isLetterOrNumber('a') = true CharUtil.isLetterOrNumber('A') = true CharUtil.isLetterOrNumber('3') = true CharUtil.isLetterOrNumber('-') = false CharUtil.isLetterOrNumber('\n') = false CharUtil.isLetterOrNumber('©') = false
ch
- 被检查的字符public static String toString(char c)
c
- 字符ASCIIStrCache.toString(char)
public static boolean isCharClass(Class<?> clazz)
Character.class char.class
clazz
- 被检查的类public static boolean isChar(Object value)
Character.class char.class
value
- 被检查的对象public static boolean isBlankChar(char c)
c
- 字符Character.isWhitespace(int)
,
Character.isSpaceChar(int)
public static boolean isBlankChar(int c)
c
- 字符Character.isWhitespace(int)
,
Character.isSpaceChar(int)
public static boolean isEmoji(char c)
c
- 字符public static boolean isFileSeparator(char c)
c
- 字符public static boolean equals(char c1, char c2, boolean ignoreCase)
c1
- 字符1c2
- 字符2ignoreCase
- 是否忽略大小写public static int getType(int c)
c
- 字符public static int digit16(int b)
b
- 字符Copyright © 2021. All rights reserved.