public class TextUtility extends Object
| Constructor and Description |
|---|
TextUtility() |
| Modifier and Type | Method and Description |
|---|---|
static int |
charType(char c) |
static int |
charType(String str)
判断字符类型
|
static int |
cint(String str)
把表示数字含义的字符串转成整形
|
static String |
combine(List<Word> wordList) |
static String |
combine(Sentence sentence) |
static String |
combine(String... termArray) |
static int |
count(String keyword,
String srcText)
统计 keyword 在 srcText 中的出现次数
|
static String |
exceptionToString(Exception e)
将异常转为字符串
|
static int |
getCharCount(String charSet,
String word)
得到字符集的字符在字符串中出现的次数
|
static int |
getUnsigned(byte b)
获取字节对应的无符号整型数
|
static boolean |
isAllChinese(String str)
是否全是中文
|
static boolean |
isAllChineseNum(String word)
是否全是中国数字
|
static boolean |
isAllDelimiter(byte[] sString)
是否全是分隔符
|
static boolean |
isAllIndex(byte[] sString)
是否全是序号
|
static boolean |
isAllLetter(String text)
是否全为英文
|
static boolean |
isAllLetterOrNum(String text)
是否全为英文或字母
|
static boolean |
isAllNonChinese(byte[] sString)
是否全部不是中文
|
static boolean |
isAllNum(String str)
是否全是数字
|
static boolean |
isAllSingleByte(String str)
是否全是单字节
|
static boolean |
isBlank(CharSequence cs)
判断字符串是否为空(null和空格)
|
static boolean |
isChinese(char c)
判断某个字符是否为汉字
|
static boolean |
isDBCCase(String str)
判断该字符串是否是半角字符
|
static boolean |
isDelimiter(String str)
判断是否是一个连字符(分隔符)
|
static boolean |
isInAggregate(String aggr,
String str)
判断一个字符串的所有字符是否在另一个字符串集合中
|
static boolean |
isSBCCase(String str)
判断该字符串是否是全角字符
|
static boolean |
isUnknownWord(String word) |
static boolean |
isYearTime(String snum)
判断字符串是否是年份
|
static String |
join(Iterable<? extends CharSequence> s,
String delimiter) |
static String |
join(String delimiter,
Collection<String> stringCollection) |
static char[] |
long2char(long x)
转换long型为char数组
|
static String |
long2String(long x)
转换long类型为string
|
static double |
nonZero(double frequency)
防止频率为0发生除零错误
|
static void |
writeString(String s,
DataOutputStream out)
简单好用的写String方式
|
public static int charType(char c)
public static int charType(String str)
str - public static boolean isAllChinese(String str)
str - public static boolean isAllNonChinese(byte[] sString)
sString - public static boolean isAllSingleByte(String str)
str - public static int cint(String str)
str - 要转换的字符串public static boolean isAllNum(String str)
str - public static boolean isAllIndex(byte[] sString)
sString - public static boolean isAllLetter(String text)
text - public static boolean isAllLetterOrNum(String text)
text - public static boolean isAllDelimiter(byte[] sString)
sString - public static boolean isAllChineseNum(String word)
word - public static int getCharCount(String charSet, String word)
charSet - word - public static int getUnsigned(byte b)
b - public static boolean isYearTime(String snum)
snum - public static boolean isInAggregate(String aggr, String str)
aggr - 字符串集合str - 需要判断的字符串public static boolean isDBCCase(String str)
str - public static boolean isSBCCase(String str)
str - public static boolean isDelimiter(String str)
str - public static boolean isUnknownWord(String word)
public static double nonZero(double frequency)
frequency - public static char[] long2char(long x)
x - public static String long2String(long x)
x - public static String exceptionToString(Exception e)
e - public static boolean isChinese(char c)
c - 需要判断的字符public static int count(String keyword, String srcText)
keyword - srcText - public static void writeString(String s, DataOutputStream out) throws IOException
s - out - IOExceptionpublic static boolean isBlank(CharSequence cs)
cs - public static String join(String delimiter, Collection<String> stringCollection)
public static String join(Iterable<? extends CharSequence> s, String delimiter)
Copyright © 2014–2021 码农场. All rights reserved.