java.lang.Object
org.seppiko.commons.utils.StringUtil
String Util
- Author:
- Leonard Woo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CharBuffercharsetDecode(Charset charset, byte[] data) Charset decodestatic byte[]charsetEncode(Charset charset, CharBuffer data) Charset encodestatic char[]convertToCharArray(String src, String split) Delete string Separator and to char arraystatic StringconvertToString(char[] src, int splitNum, String split) Convert char array to String with separatestatic StringfixedLength(String str, int length, char preChar) return fixed length string objectstatic booleantest string has any charstatic booleanhasText(CharSequence str) test char sequence has any char without whitespacestatic booleantest string has any char without whitespacestatic StringinitialsUpperCase(String str) capitalize the first letterstatic booleantest string is null or length is 0static StringreplaceIndex(CharSequence data, int start, int end, CharSequence replacement) replace CharSequence between start and endstatic StringGet a string object with default valuestatic Stringtranscoding(String data, Charset oldEncoding, Charset newEncoding) convert string data from old encoding to new encoding
-
Constructor Details
-
StringUtil
public StringUtil()
-
-
Method Details
-
safeNull
Get a string object with default value- Parameters:
src- string objectdefaultValue- default string object- Returns:
- result
-
isEmpty
test string is null or length is 0- Parameters:
str- string object- Returns:
- true is yes
-
hasLength
test string has any char- Parameters:
str- string object- Returns:
- true is yes
-
hasText
test char sequence has any char without whitespace- Parameters:
str- char sequence object- Returns:
- true is yes
-
hasText
test string has any char without whitespace- Parameters:
str- string object- Returns:
- true is yes
-
transcoding
convert string data from old encoding to new encoding- Parameters:
data- string dataoldEncoding- old encodingnewEncoding- new encoding- Returns:
- convert result
-
fixedLength
return fixed length string object- Parameters:
str- string objectlength- lengthpreChar- pre-padded character- Returns:
- fixed length string object
-
initialsUpperCase
capitalize the first letter- Parameters:
str- origin string- Returns:
- new string
-
replaceIndex
replace CharSequence between start and end- Parameters:
data- origin datastart- replace start indexend- replace end indexreplacement- replace data- Returns:
- new data string
-
convertToString
Convert char array to String with separate- Parameters:
src- Raw datasplitNum- Separation intervalsplit- Separator- Returns:
- encoded string
-
convertToCharArray
Delete string Separator and to char array- Parameters:
src- Datasplit- Separator- Returns:
- char array
-
charsetDecode
Charset decode- Parameters:
charset- charset, e.g.StandardCharsets.UTF_8data- byte array- Returns:
- character buffer object
- See Also:
-
charsetEncode
Charset encode- Parameters:
charset- charset, e.g.StandardCharsets.UTF_8data- character buffer- Returns:
- byte array
- See Also:
-