Package org.ximinghui.common.util
Class Strings
java.lang.Object
org.apache.commons.lang3.StringUtils
org.ximinghui.common.util.Strings
public class Strings
extends org.apache.commons.lang3.StringUtils
字符串工具类
- Since:
- Common Util 3.12.0.1
- Author:
- Xi Minghui
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String数字或(不区分大小写)字母匹配模式static final String连字符static final String换行符匹配模式static final String下划线Fields inherited from class org.apache.commons.lang3.StringUtils
CR, EMPTY, INDEX_NOT_FOUND, LF, SPACE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String生成一个由随机数字字符组成的字符串static StringrandomDigitString(int length) 生成一个由随机数字字符组成的指定长度字符串static StringrandomDigitString(int length, boolean startsWithZero) 生成一个由随机数字字符组成且指定是否允许以0开头的指定长度字符串static String从给定字符集中随机获取非控制字符的字符串static StringrandomNonControlChars(Characters.CharacterSet charSet, int length) 从给定字符集中随机获取非控制字符的字符串static StringrandomVisibleChar(Characters.CharacterSet charSet) 从给定字符集中随机获取字符可见的字符串static StringrandomVisibleChars(Characters.CharacterSet charSet, int length) 从给定字符集中随机获取字符可见的字符串static StringreplaceAllSpaces(String string, Character replacement) 替换字符串中出现的所有空格为指定字符static StringreplaceAllSpaces(String string, String replacement) 替换字符串中出现的所有空格为指定字符串static StringreplaceFirstSpace(String string, Character replacement) 替换字符串中出现的首个空格为指定字符static StringreplaceFirstSpace(String string, String replacement) 替换字符串中出现的首个空格为指定字符串static String获取对象toString字符串右边指定位数的子字符串static String[]splitLineAsArray(String string) 将字符串按行切分为数组splitLineAsList(String string) 将字符串按行切分为List序列Methods inherited from class org.apache.commons.lang3.StringUtils
abbreviate, abbreviate, abbreviate, abbreviate, abbreviateMiddle, appendIfMissing, appendIfMissingIgnoreCase, capitalize, center, center, center, chomp, chomp, chop, compare, compare, compareIgnoreCase, compareIgnoreCase, contains, contains, containsAny, containsAny, containsAny, containsAnyIgnoreCase, containsIgnoreCase, containsNone, containsNone, containsOnly, containsOnly, containsWhitespace, countMatches, countMatches, defaultIfBlank, defaultIfEmpty, defaultString, defaultString, deleteWhitespace, difference, endsWith, endsWithAny, endsWithIgnoreCase, equals, equalsAny, equalsAnyIgnoreCase, equalsIgnoreCase, firstNonBlank, firstNonEmpty, getBytes, getBytes, getCommonPrefix, getDigits, getFuzzyDistance, getIfBlank, getIfEmpty, getJaroWinklerDistance, getLevenshteinDistance, getLevenshteinDistance, indexOf, indexOf, indexOf, indexOf, indexOfAny, indexOfAny, indexOfAny, indexOfAnyBut, indexOfAnyBut, indexOfDifference, indexOfDifference, indexOfIgnoreCase, indexOfIgnoreCase, isAllBlank, isAllEmpty, isAllLowerCase, isAllUpperCase, isAlpha, isAlphanumeric, isAlphanumericSpace, isAlphaSpace, isAnyBlank, isAnyEmpty, isAsciiPrintable, isBlank, isEmpty, isMixedCase, isNoneBlank, isNoneEmpty, isNotBlank, isNotEmpty, isNumeric, isNumericSpace, isWhitespace, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, joinWith, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOfAny, lastIndexOfIgnoreCase, lastIndexOfIgnoreCase, lastOrdinalIndexOf, left, leftPad, leftPad, leftPad, length, lowerCase, lowerCase, mid, normalizeSpace, ordinalIndexOf, overlay, prependIfMissing, prependIfMissingIgnoreCase, remove, remove, removeAll, removeEnd, removeEndIgnoreCase, removeFirst, removeIgnoreCase, removePattern, removeStart, removeStartIgnoreCase, repeat, repeat, repeat, replace, replace, replaceAll, replaceChars, replaceChars, replaceEach, replaceEachRepeatedly, replaceFirst, replaceIgnoreCase, replaceIgnoreCase, replaceOnce, replaceOnceIgnoreCase, replacePattern, reverse, reverseDelimited, right, rightPad, rightPad, rightPad, rotate, split, split, split, split, splitByCharacterType, splitByCharacterTypeCamelCase, splitByWholeSeparator, splitByWholeSeparator, splitByWholeSeparatorPreserveAllTokens, splitByWholeSeparatorPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, startsWith, startsWithAny, startsWithIgnoreCase, strip, strip, stripAccents, stripAll, stripAll, stripEnd, stripStart, stripToEmpty, stripToNull, substring, substring, substringAfter, substringAfter, substringAfterLast, substringAfterLast, substringBefore, substringBefore, substringBeforeLast, substringBetween, substringBetween, substringsBetween, swapCase, toCodePoints, toEncodedString, toRootLowerCase, toRootUpperCase, toString, trim, trimToEmpty, trimToNull, truncate, truncate, uncapitalize, unwrap, unwrap, upperCase, upperCase, valueOf, wrap, wrap, wrapIfMissing, wrapIfMissing
-
Field Details
-
UNDERSCORE
下划线- See Also:
-
HYPHEN
连字符- See Also:
-
DIGIT_OR_ALPHABET_PATTERN
数字或(不区分大小写)字母匹配模式- See Also:
-
LINE_SEPARATOR_PATTERN
换行符匹配模式- See Also:
-
-
Constructor Details
-
Strings
public Strings()
-
-
Method Details
-
randomNonControlChar
从给定字符集中随机获取非控制字符的字符串- Parameters:
charSet- 字符集- Returns:
- 随机非控制字符的字符串
-
randomNonControlChars
从给定字符集中随机获取非控制字符的字符串- Parameters:
charSet- 字符集length- 字符串长度- Returns:
- 随机非控制字符的字符串
-
randomVisibleChar
从给定字符集中随机获取字符可见的字符串与
随机非控制字符的字符串方法不同的是, 该方法不会生成包含空白符(如空格)的字符串。- Parameters:
charSet- 字符集- Returns:
- 随机字符可见的字符串
-
randomVisibleChars
从给定字符集中随机获取字符可见的字符串- Parameters:
charSet- 字符集length- 字符串长度- Returns:
- 随机字符可见的字符串
-
replaceFirstSpace
替换字符串中出现的首个空格为指定字符串- Parameters:
string- 待处理字符串replacement- 替换字符串- Returns:
- 替换后的字符串
-
replaceFirstSpace
替换字符串中出现的首个空格为指定字符- Parameters:
string- 待处理字符串replacement- 替换字符- Returns:
- 替换后的字符串
-
replaceAllSpaces
替换字符串中出现的所有空格为指定字符串- Parameters:
string- 待处理字符串replacement- 替换字符串- Returns:
- 替换后的字符串
-
replaceAllSpaces
替换字符串中出现的所有空格为指定字符- Parameters:
string- 待处理字符串replacement- 替换字符串- Returns:
- 替换后的字符串
-
splitLineAsArray
将字符串按行切分为数组- Parameters:
string- 字符串- Returns:
- 字符串数组
-
splitLineAsList
将字符串按行切分为List序列- Parameters:
string- 字符串- Returns:
- 字符串序列
-
randomDigitString
生成一个由随机数字字符组成的字符串- Returns:
- 单随机数字字符组成的字符串
-
randomDigitString
生成一个由随机数字字符组成的指定长度字符串- Parameters:
length- 生成字符串长度- Returns:
- 随机数字字符组成的指定长度字符串
-
randomDigitString
生成一个由随机数字字符组成且指定是否允许以0开头的指定长度字符串- Parameters:
length- 生成字符串长度startsWithZero- 是否允许以0开头- Returns:
- 随机数字字符组成且指定是否允许以0开头的指定长度字符串
-
right
获取对象toString字符串右边指定位数的子字符串- Parameters:
object- 转换为字符串的对象length- 指定长度- Returns:
- 自右指定长度的子字符串
-