public class StringUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_EMPTY_STRING |
| Modifier and Type | Method and Description |
|---|---|
static String |
abbreviateFromLeft(String str,
int size)
substring the leftmost len characters of a String with ellipsis. ex)
abbreviateFromLeft("12345678", 3) ≥ "123..."
|
static String |
abbreviateFromRight(String str,
int size)
substring the rightmost len characters of a String with ellipsis. ex)
abbreviateFromRight("12345678", 3) ≥ "...678"
|
static String |
addSpace(String str,
int size)
Appends spaces to Stringwidth the input length.
|
static String[] |
addStringToArray(String[] strings,
String str)
Appends a string to string array.
|
static String |
applyInitialLaw(String str)
Apply initial law to String.
|
static String |
arrayToCommaDelimitedString(Object[] array)
Deprecated.
|
static String |
arrayToDelimitedString(Object[] objects)
Joins the elements of the provided array into a single String containing
the provided list of elements. ex) String[] test = {"aaa", "bbb", "ccc"};
arrayToDelimitedString(test) ≥ "aaa,bbb,ccc"
|
static String |
arrayToDelimitedString(Object[] objects,
String delimiter)
Joins the elements of the provided array into a single String containing
the provided list of elements.
|
static String |
asteriskToSpace(String str)
Converts asterisk to space in a String.
|
static String |
collectionToCommaDelimitedString(Collection<String> collection)
Deprecated.
|
static String |
collectionToDelimitedString(Collection<String> strings)
Joins the elements of the provided collection into a single String
containing the provided list of elements with comma delimeter.
|
static String |
collectionToDelimitedString(Collection<String> strings,
String delimiter)
Joins the elements of the provided collection into a single String
containing the provided list of elements with delimeter.
|
static Set<String> |
commaDelimitedStringToSet(String str)
Converts a single String with comma delimiter to Set of String.
|
static String[] |
commaDelimitedStringToStringArray(String str)
Deprecated.
|
static int |
compareTo(String sourceStr,
String targetStr)
Compare two words in lexicographical order. if the input string or string
to compare with is
null, return -1. |
static int |
compareToIgnoreCase(String sourceStr,
String targetStr)
Compare two words in lexicographical order. if the input string or string
to compare with is
null, return -1. |
static boolean |
containsAny(String str,
char[] chars)
Checks that the String contains certain characters.
|
static boolean |
containsAny(String str,
String chars)
Checks that the String contains certain characters.
|
static boolean |
containsInvalidChars(String str,
char[] invalidChars)
Deprecated.
|
static boolean |
containsInvalidChars(String str,
String invalidChars)
Deprecated.
|
static boolean |
containsMaxOccurences(String str,
String maxSeqNumber)
It returns true if string contains a sequence of the same character.
|
static boolean |
containsMaxSequence(String str,
String maxSeqNumber)
Deprecated.
|
static String |
convertStringCharset(String str,
String charset)
Converts this String into a sequence of bytes using the named charset,
storing the result into a new String
|
static String |
convertToCamelCase(String str)
Convert a string that may contain underscores to camel case.
|
static String |
convertToCamelCase(String str,
char delimiter)
Convert a camel case string to underscore representation.
|
static String |
convertToUnderScore(String str)
Convert a camel case string to underscore representation.
|
static int |
countMatches(String str,
char[] chars)
For given string, return number that includes related characters.
|
static int |
countMatches(String str,
String sub)
For the given string, return the number that includes the related string.
|
static int |
countMatchesIgnoreCase(String str,
char[] chars)
For given string regardless of upper case or lower case letters, return
number that includes related characters.
|
static int |
countMatchesIgnoreCase(String str,
String sub)
For the given string, return the number that includes related string,
regardless of upper case or lower case letters.
|
static int |
countPattern(String str,
String pattern)
Deprecated.
|
static String |
decode(String source,
String target,
String result,
String base)
Compare the first and second string.
|
static String |
deleteAny(String str,
char charToDelete)
Removes all occurrences of a character from within the source string. ex)
deleteAny("ABBBBBC", 'B') ≥ "AC"
|
static String |
deleteAny(String str,
char[] charsToDelete)
Removes all occurrences of given chars from within the source string.
|
static String |
deleteAny(String str,
String charsToDelete)
For input strings, remove all strings to be deleted.
|
static String |
deleteChars(String str,
String chars)
Deprecated.
|
static String |
deleteFirstMatches(String str,
String deletedStr)
For input strings, remove matched strings to be deleted.
|
static String |
deleteMatches(String str,
String subStr)
For input strings, remove matched strings to be deleted.
|
static String |
deletePattern(String str,
String pattern)
Deprecated.
|
static String[] |
delimitedStringToStringArray(String str,
String delimiter)
Deprecated.
|
static String |
fillString(String str,
char padChar,
int ciphers)
Deprecated.
|
static int |
getByteLength(char ch)
Return byte length for each letter of related character
|
static int |
getByteLength(String str)
Return total length of related string calculated in byte unit.
|
static int |
getContainsCount(String str,
char[] chars)
Deprecated.
|
static int |
getContainsCount(String str,
String sub)
Deprecated.
|
static int |
getContainsCountIgnoreCase(String str,
char[] chars)
Deprecated.
|
static int |
getContainsCountIgnoreCase(String str,
String sub)
Deprecated.
|
static String |
getCutString(String str,
int length)
Deprecated.
|
static String |
getLastString(String str,
String token)
Break a string into specific tokens and return a String of last location.
|
static int |
getLength(String str)
Return length of related string.
|
static String |
getRandomString(int size)
Return a specific length of random string.
|
static String |
getRandomString(int size,
char startChar,
char endChar)
Return random string of a defined length between specific alphabet
character.
|
static String |
getRandomString(int minSize,
int maxSize)
Return random string between minimum and maximum digits.
|
static String |
getRandomStringByCharset(int size,
String charset)
Return a specific length of given character set string.
|
static String |
getRandomStringByKorean(int size)
Return a specific length of random string in Korean characters (UTF-8
only).
|
static String[] |
getStringArray(String str,
String strToken)
Deprecated.
|
static List<String> |
getTokens(String str)
Return token list which is separated by ","
|
static List<String> |
getTokens(String str,
String delimeter)
Return token list which is separated by input delimiter
|
static boolean |
hasLength(String str)
Checks if String length is greater than zero. ex) "test" ≥ true "" ≥
false
|
static boolean |
hasText(String str)
Checks if String contains no whitespace. ex) hasText(" test ") ≥ true
hasText(" ") ≥ false hasText("") ≥ false
|
static String |
hexToString(String str)
Converts hex code to UniCode String
|
static String |
htmlEscape(String input)
Unescape string that includes HTML escape characters.
|
static String |
htmlUnescape(String input)
Input string to HTML tag format.
|
static int |
indexOf(String str,
String search)
If the string that is searched for is included in the input string,
return the index of the first string.
|
static int |
indexOfIgnoreCase(String str,
String search)
If the string to be searched for is included in input string, regardless
of upper case or lower case letters, return the first string.
|
static String |
integer2string(int integer)
Deprecated.
|
static boolean |
isAlpha(String str)
Deprecated.
Use
isLetter(String) |
static boolean |
isAlphaNumeric(String str)
Deprecated.
|
static boolean |
isDigit(String str)
Deprecated.
Use @link
NumberUtils.isDigits(String) |
static boolean |
isEmpty(String str)
If string is null or empty string, return true.
|
static boolean |
isEmptyTrimmed(String str)
Determine whether a (trimmed) string is empty
|
static boolean |
isFormattedString(String str,
String regex)
Deprecated.
|
static boolean |
isHangul(char achar)
Checks if the String contains only Korean characters. ex) isHangul('가')
≥ true isHangul('T') ≥ false
|
static boolean |
isHangul(String str,
boolean checkForAll)
Checks if the String contains only Korean characters or any Korean
characters. ex) isHangul("가나다", true) ≥ true isHangul("가나다abc", true) ≥
false isHangul("가abc", false) ≥ true isHangul("abcd", false) ≥ false
|
static boolean |
isLetter(String str)
Checks if the String contains only letters. ex) isLetter("test") ≥ true
isLetter("test#$%") ≥ false isLetter("test123") ≥ false isLetter("")≥
false
|
static boolean |
isLetterOrDigit(String str)
Checks if the String contains only letters or digits. ex)
isLetterOrDigit("12abC") ≥ true isLetterOrDigit("12@#%")≥ false
|
static boolean |
isNotEmpty(String str)
If string is null or empty string, return false.
|
static boolean |
isNotNumeric(String str)
Deprecated.
|
static boolean |
isNumeric(String str)
Deprecated.
in favor of @link
NumberUtils.isNumber(String) |
static boolean |
isPatternInclude(String str,
String param)
Check if input string matches the given filter pattern. s of sken is
special character. k is korean. e is english. n is number.
|
static boolean |
isPatternMatching(String str,
String pattern)
Check if the input string matches the formal pattern.
|
static boolean |
isRegexPatternInclude(String str,
String pattern)
Check if some strings match pattern.
|
static boolean |
isRegexPatternMatch(String str,
String pattern)
Check if the entire pattern matches the formal input pattern.
|
static boolean |
isSpaceOnly(String str)
Deprecated.
|
static boolean |
isUserFormat(String str,
String pattern)
Check if letter matching format defined by user has come in.
|
static boolean |
isWhiteSpaceOnly(String str)
Checks if the CharSequence contains only whitespace. ex)
isWhiteSpaceOnly(" ") ≥ true isWhiteSpaceOnly("") ≥ true
isWhiteSpaceOnly("test") ≥ false
|
static String |
left(String str,
int size)
Gets the leftmost len characters of a String. ex) left("1234567", 3) ≥
"123"
|
static String |
leftPad(String str,
int size)
For related string, fill the input length from the left with space.
|
static String |
leftPad(String str,
int size,
char padChar)
For related string, fill the input length from the left with defined
letter.
|
static String |
leftPad(String str,
int size,
String padStr)
For related string, fill the input length from the left with defined
string.
|
static String |
leftTrim(String str)
Delete the space string on the left of the string.
|
static String |
newLineToSpace(String str)
Converts CR/LF characters to a space in a String. ex)
newLineToSpace("\r\ntest") ≥ " test"
|
static String |
null2str(String org)
Deprecated.
|
static String |
null2str(String org,
String converted)
Deprecated.
|
static String |
nullToEmpty(String str)
Returns empty string if the given String is null, returns given String if
not. ex) nullToEmpty("test") ≥ "test" String test = null;
nullToEmpty(test) ≥ ""
|
static Object |
nullToObject(Object obj,
Object defaultObj)
Returns the default Object if the given Object is null. ex) String test =
null; System.out.println(nullToObject(test, "NULL TEST")) ≥ "NULL TEST"
String test = "test"; System.out.println(nullToObject(test, "NULL TEST"))
≥ "test"
|
static String |
nullToString(String org)
Trim the original string.
|
static String |
nullToString(String str,
String defaultStr)
Trim the original string.
|
static String |
numberFormat(double d,
String format)
Deprecated.
|
static String |
numberFormat(float f,
String format)
Deprecated.
|
static String |
numberFormat(int i,
String format)
Deprecated.
|
static String |
numberFormat(long l,
String format)
Deprecated.
|
static String |
numberFormat(short s,
String format)
Deprecated.
|
static Object |
nvl(Object inputObject,
Object defaultObject)
Deprecated.
|
static String |
nvl(String inputString,
String defaultString)
Deprecated.
|
static String |
padding(int size,
char padChar)
Deprecated.
|
static String |
pathClean(String path)
Normalize the path String. ex) pathClean("..
|
static boolean |
pathEquals(String path1,
String path2)
Compare both path String after nomalization. ex)
pathEquals("..
|
static String |
removeAll(String str,
String charsToDelete)
Deprecated.
|
static String |
removeChar(String str,
char remove)
Deprecated.
|
static String |
removeCharAll(String str)
Deprecated.
|
static String |
removeCharAll(String str,
char[] remove)
Deprecated.
|
static String |
removeEscapeChar(String str)
Deprecated.
|
static String |
removeWhitespace(String str)
Delete all space strings.
|
static String |
repeat(int size,
char ch)
Gets the String with a specified character.
|
static String |
replace(String str,
String replacedStr,
String replacement)
Deprecated.
|
static String |
replaceAll(String str,
String regex,
String replacement)
Replaces each substring of this string that matches the given regular
expression with the given replacement.
|
static String |
replaceFirst(String src,
String regex,
String replacement)
Replaces the first substring of this string that matches the given
regular expression with the given replacement.
|
static String |
replaceHtmlEscape(String str)
Deprecated.
|
static String |
replaceLast(String str,
String regex,
String replacement)
Replaces the last substring of this string that matches the given regular
expression with the given replacement.
|
static String |
replacePattern(String str,
String replacedStr,
String replacement)
Deprecated.
|
static String |
reverse(String str)
Reverses a String as per
StringBuffer.reverse(). |
static String |
right(String str,
int size)
Gets the rightmost len characters of a String. ex) right("1234567", 3) ≥
"567"
|
static String |
rightPad(String str,
int size)
For related string, fill the input length from the right with space.
|
static String |
rightPad(String str,
int size,
char padChar)
For related string, fill the input length from the right with defined
letter.
|
static String |
rightPad(String str,
int size,
String padStr)
For related string, fill the input length from the right with defined
string.
|
static String |
rightTrim(String str)
Delete the space string on the right of the string.
|
static String[] |
split(String str,
char separator)
Deprecated.
|
static String |
splitHead(String str,
int size)
Deprecated.
|
static String |
splitHeadWithEllipsis(String str,
int len)
Deprecated.
|
static String |
splitTail(String str,
int size)
Deprecated.
|
static String |
splitTailWithEllipsis(String str,
int len)
Deprecated.
|
static int |
string2integer(String str)
Deprecated.
|
static BigDecimal |
stringToBigDecimal(String str)
Deprecated.
|
static BigDecimal |
stringToBigDecimal(String str,
int pos,
int len)
Deprecated.
|
static String |
stringToHex(String str)
Converts UniCode String to hex code ex) stringToHex("123") ≥
"003100320033"
|
static int |
stringToNumn(String str)
Deprecated.
|
static int |
stringToNumn(String str,
int pos,
int len)
Deprecated.
|
static String |
swapFirstLetterCase(String str)
convert first letter to a big letter or a small letter.
|
static String |
toBusinessNoPattern(String str)
Converts 10 digit String to business number format(Korean). ex)
toBusinessNoPattern("1111111111") ≥ "111-11-11111"
|
static String[] |
tokenizeToStringArray(String str)
Splits the provided text into an array, separator specified. ex) String[]
test; test = tokenizeToStringArray("aaa,bbb,ccc") ≥ test[0]="aaa",
test[1]="bbb"...
|
static String[] |
tokenizeToStringArray(String str,
char delimeter)
Splits the provided text into an array, separator specified. ex) String[]
test; test = tokenizeToStringArray("aaa,bbb,ccc", ',') ≥ test[0]="aaa",
test[1]="bbb"...
|
static String[] |
tokenizeToStringArray(String str,
String delimiter)
Splits the provided text into an array, separator specified. ex) String[]
test; test = tokenizeToStringArray("aaa.bbb.ccc.ddd", "."); ≥
test[0]="aaa", test[1]="bbb"...
|
static String[] |
tokenizeToStringArray(String str,
String delimeter,
boolean trimTokens,
boolean ignoreEmptyTokens)
Splits the provided text into an array, separator specified. ex) String[]
test; test = tokenizeToStringArray("aaa.bbb.ccc.ddd", "
|
static String |
toLowercase(String str)
Deprecated.
|
static String |
toLowerCaseFirstLetter(String str)
Converts a first character to lower case. ex)
toLowerCaseFirstLetter("ABCD") ≥ "aBCD"
|
static String |
toSocialSecuNoPattern(String str)
Converts 13 digit String to social security number format(Korean). ex)
toSocialSecuNoPattern("1111111111111") ≥ "111111=1111111"
|
static String |
toTelephoneNumberFormat(String str)
Converts digit String to telephone number format(Korean).
|
static String |
toUpperCase(String str)
Deprecated.
|
static String |
toUpperCaseFirstLetter(String str)
Converts a first character to uppper case. ex)
toUpperCaseFirstLetter("abcd") ≥ "Abcd"
|
static String |
toZipCodePattern(String str)
Converts digit String to zip code format(Korean). ex)
toZipCodePattern("111111") ≥ "111-111"
|
static String |
trim(String origString,
String trimString)
Deprecated.
|
static boolean |
trimEquals(String str1,
String str2)
Compares two Strings with whitespace normalized by using trim ex)
trimEquals(" test ", "test") ≥ true
|
static String |
unqualify(String str)
Converts qualified name String to unqualified name String using separator
'.'.
|
static String |
unqualify(String str,
char delimiter)
Converts qualified name String to unqualified name String using
separator.
|
public static final String DEFAULT_EMPTY_STRING
public static String addSpace(String str, int size)
str - string to be modifiedsize - length of spaces@Deprecated public static String fillString(String str, char padChar, int ciphers)
leftPad(String, int, char)str - original StringpadChar - a special charciphers - cipherspublic static String[] addStringToArray(String[] strings, String str)
strings - string array to be modifiedstr - string to be appendedpublic static String applyInitialLaw(String str)
str - string to be modified@Deprecated public static String arrayToCommaDelimitedString(Object[] array)
array - the array of values to join togetherpublic static String arrayToDelimitedString(Object[] objects)
objects - the array of values to join togetherpublic static String arrayToDelimitedString(Object[] objects, String delimiter)
objects - the array of values to join togetherdelimiter - delimiter for conversioin@Deprecated public static String collectionToCommaDelimitedString(Collection<String> collection)
collection - the collection of values to join togetherpublic static String collectionToDelimitedString(Collection<String> strings)
strings - the collection of values to join togetherpublic static String collectionToDelimitedString(Collection<String> strings, String delimiter)
strings - the collection of values to join togetherdelimiter - delimiter for conversioinpublic static Set<String> commaDelimitedStringToSet(String str)
str - the single String to convert with comma delimiter@Deprecated public static String[] commaDelimitedStringToStringArray(String str)
tokenizeToStringArray(String)str - the silgle String to convertpublic static String asteriskToSpace(String str)
str - string to be convertedpublic static String swapFirstLetterCase(String str)
StringUtil.swapFirstLetterCase("Password") = "password'
StringUtil.swapFirstLetterCase("password') = "Password"
str - String to be swappedpublic static int compareTo(String sourceStr, String targetStr)
null, return -1.sourceStr - input stringtargetStr - string to be compared with If return value is 0, the same
word, if it is under 0, the smaller one in lexicographical
order, if it is over 0, the bigger one in lexicographical
order.String.compareTo(String)public static int compareToIgnoreCase(String sourceStr, String targetStr)
null, return -1.sourceStr - input stringtargetStr - string to be compared withString.compareToIgnoreCase(String)@Deprecated public static boolean containsInvalidChars(String str, char[] invalidChars)
containsAny(String, char[])null String will return false. A
null invalid character array will return false.
An empty String ("") always returns false.
StringUtil.containsInvalidChars(null, *) = false
StringUtil.containsInvalidChars(*, null) = false
StringUtil.containsInvalidChars("", *) = false
StringUtil.containsInvalidChars("ab", "") = false
StringUtil.containsInvalidChars("abab", "xyz") = false
StringUtil.containsInvalidChars("ab1", 'xyz") = false
StringUtil.containsInvalidChars("xbz", "xyz") = true
str - the String to check, may be nullinvalidChars - an array of invalid chars, may be nullpublic static boolean containsAny(String str, char[] chars)
null String will return false. A
null invalid character array will return false.
An empty String ("") always returns false.
StringUtil.containsAny(null, *) = false
StringUtil.containsAny(*, null) = false
StringUtil.containsAny("", *) = false
StringUtil.containsAny("ab", "".toCharArrray()) = false
StringUtil.containsAny("abab", "xyz".toCharArray()) = false
StringUtil.containsAny("ab1", 'xyz".toCharArray()) = false
StringUtil.containsAny("xbz", "xyz".toCharArray()) = true
str - the String to check, may be nullchars - an array of invalid chars, may be null@Deprecated public static boolean containsInvalidChars(String str, String invalidChars)
containsAny(String, String)null String will return false. A
null invalid character array will return false.
An empty String ("") always returns false.
StringUtil.containsInvalidChars(null, *) = false
StringUtil.containsInvalidChars(*, null) = false
StringUtil.containsInvalidChars("", *) = false
StringUtil.containsInvalidChars("ab", "") = false
StringUtil.containsInvalidChars("abab", "xyz") = false
StringUtil.containsInvalidChars("ab1", "xyz") = false
StringUtil.containsInvalidChars("xbz", "xyz") = true
str - the String to check, may be nullinvalidChars - a String of invalid chars, may be nullpublic static boolean containsAny(String str, String chars)
null String will return false. A
null character array will return false. An
empty String ("") always returns false.
StringUtil.containsAny(null, *) = false
StringUtil.containsAny(*, null) = false
StringUtil.containsAny("", *) = false
StringUtil.containsAny("ab", "") = false
StringUtil.containsAny("abab", "xyz") = false
StringUtil.containsAny("ab1", "xyz") = false
StringUtil.containsAny("xbz", "xyz") = true
str - the String to check, may be nullchars - a String of invalid chars, may be null@Deprecated public static boolean containsMaxSequence(String str, String maxSeqNumber)
containsMaxOccurences(String, String)
StringUtil.containsMaxSequence("password", "2") = true
StringUtil.containsMaxSequence("my000", "3") = true
StringUtil.containsMaxSequence("abbbbc", "5") = false
str - original StringmaxSeqNumber - a sequence of the same characterpublic static boolean containsMaxOccurences(String str, String maxSeqNumber)
StringUtil.containsMaxOccurences("password", "2") = true
StringUtil.containsMaxOccurences("my000", "3") = true
StringUtil.containsMaxOccurences("abbbbc", "5") = false
str - original StringmaxSeqNumber - a sequence of the same characterpublic static String convertToCamelCase(String str)
str - the String to convertpublic static String convertToCamelCase(String str, char delimiter)
str - Camel case name.delimiter - delimiter for conversioinpublic static String convertToUnderScore(String str)
str - the String to convert@Deprecated public static int countPattern(String str, String pattern)
countMatches(String, String)str - the String to checkpattern - the pattern to countpublic static String decode(String source, String target, String result, String base)
source - value to compare.target - value that is compared against sourceresult - value returnedbase - optional string@Deprecated public static String deleteChars(String str, String chars)
deleteAny(String, String)str - the source String to searchchars - the char to search for and remove@Deprecated public static String deletePattern(String str, String pattern)
deleteMatches(String, String)str - the source String to searchpattern - the String to search for and remove@Deprecated public static String[] delimitedStringToStringArray(String str, String delimiter)
tokenizeToStringArray(String, String)str - the silgle String to convertdelimiter - delimiter for conversioinpublic static int getByteLength(char ch)
ch - one English letterpublic static int getByteLength(String str)
str - input string@Deprecated public static int getContainsCount(String str, char[] chars)
null, return
-1.str - input stringchars - character arrangement to be searched forpublic static int countMatches(String str, char[] chars)
null, return
-1.str - input stringchars - character arrangement to be searched for@Deprecated public static int getContainsCount(String str, String sub)
countMatches(String, String)str - string to search in. Return 0 if this is null.sub - string to search for. Return 0 if this is null.StringUtils.countOccurrencesOf(String,
String)public static int countMatches(String str, String sub)
str - string to search in. Return 0 if this is null.sub - string to search for. Return 0 if this is null.StringUtils.countOccurrencesOf(String,
String)@Deprecated public static int getContainsCountIgnoreCase(String str, char[] chars)
countMatchesIgnoreCase(String, char[])null, return -1.str - input stringchars - string of characters to be searched forpublic static int countMatchesIgnoreCase(String str, char[] chars)
null, return -1.str - input stringchars - string of characters to be searched for@Deprecated public static int getContainsCountIgnoreCase(String str, String sub)
countMatchesIgnoreCase(String, String)str - string to search in. Return 0 if this is null.sub - string to search for. Return 0 if this is null.StringUtils.countOccurrencesOf(String,
String)public static int countMatchesIgnoreCase(String str, String sub)
str - string to search in. Return 0 if this is null.sub - string to search for. Return 0 if this is null.StringUtils.countOccurrencesOf(String,
String)@Deprecated public static String getCutString(String str, int length)
left(String, int)str - input stringlength - length of stringpublic static String getLastString(String str, String token)
StringUtil.getLastString("password*password*a*b*c", "*") = "c"
str - original Stringtoken - specific tokenspublic static int getLength(String str)
null, return
-1.str - input stringString.length()public static String getRandomString(int size)
size - the length of random string to be developedpublic static String getRandomString(int minSize, int maxSize)
minSize - minimum digitsmaxSize - maximum digitspublic static String getRandomString(int size, char startChar, char endChar)
size - the length of random string to be madestartChar - the first letter of the random string being madeendChar - the last letter of the random string being madepublic static String getRandomStringByCharset(int size, String charset) throws UnsupportedEncodingException
size - length of random string to be madecharset - supported character setUnsupportedEncodingException - throws Un supported Encoding Exceptionpublic static String getRandomStringByKorean(int size) throws UnsupportedEncodingException
size - length of random string to be madeUnsupportedEncodingException - throws Un supported Encoding Exception@Deprecated public static String[] getStringArray(String str, String strToken)
tokenizeToStringArray(String, String)
StringUtil.getStringArray("passwordabcpassword", "abc") = String[]{"password","password"}
StringUtil.getStringArray("pasword*password", "abc") = String[]{"pasword*password"}
str - original StringstrToken - specific String tokenpublic static List<String> getTokens(String str)
str - the String to parsepublic static List<String> getTokens(String str, String delimeter)
str - the String to parsedelimeter - the String used as the delimiterpublic static boolean hasLength(String str)
str - the String to checkpublic static boolean hasText(String str)
str - the String to checkpublic static String hexToString(String str)
str - the String to convertpublic static int indexOf(String str, String search)
str - input stringsearch - string that is searched forString.indexOf(String)public static int indexOfIgnoreCase(String str, String search)
str - input stringsearch - string to be compared withString.indexOf(String)@Deprecated public static String integer2string(int integer)
StringUtil.integer2string(14) = '14'
integer - integer type@Deprecated public static boolean isAlpha(String str)
isLetter(String)null will return false. An empty String ("")
will return false.
StringUtil.isAlpha(null) = false
StringUtil.isAlpha("") = false
StringUtil.isAlpha(" ") = false
StringUtil.isAlpha("abc") = true
StringUtil.isAlpha("ab2c") = false
StringUtil.isAlpha("ab-c") = false
str - the String to check, may be nulltrue if only contains letters, and is non-null@Deprecated public static boolean isAlphaNumeric(String str)
isLetterOrDigit(String)null will return false. An empty String ("")
will return false.
StringUtil.isAlphaNumeric(null) = false
StringUtil.isAlphaNumeric("") = false
StringUtil.isAlphaNumeric(" ") = false
StringUtil.isAlphaNumeric("abc") = true
StringUtil.isAlphaNumeric("ab c") = false
StringUtil.isAlphaNumeric("ab2c") = true
StringUtil.isAlphaNumeric("ab-c") = false
str - the String to check, may be nulltrue if only contains letters or digits, and is
non-null@Deprecated public static boolean isDigit(String str)
NumberUtils.isDigits(String)str - the String to check, may be nullpublic static boolean isEmpty(String str)
StringUtil.isEmpty("") = true
StringUtil.isEmpty(null) = true
StringUtil.isEmpty("abc") = false
str - original Stringpublic static boolean isEmptyTrimmed(String str)
str - The text to check.public static boolean isHangul(char achar)
achar - the character to check, may be nullpublic static boolean isHangul(String str, boolean checkForAll)
str - the String to check, may be nullcheckForAll - flag for check only Korean characters(true) or any Korean
characters(false)public static boolean isLetter(String str)
str - the String to check, may be nullpublic static boolean isLetterOrDigit(String str)
str - the String to check, may be nullpublic static boolean isNotEmpty(String str)
StringUtil.isNotEmpty("") = false
StringUtil.isNotEmpty(null) = false
StringUtil.isNotEmpty("abc") = true
str - original String@Deprecated public static boolean isNotNumeric(String str)
str - the String to check, may be null@Deprecated public static boolean isSpaceOnly(String str)
isWhiteSpaceOnly(String)str - the String to check, may be nullpublic static boolean isWhiteSpaceOnly(String str)
str - the String to check, may be nullpublic static String left(String str, int size)
str - the String to get the leftmost characters from, may be nullsize - the length of the required Stringpublic static String leftPad(String str, int size)
StringUtil.leftPad(null, *) = null
StringUtil.leftPad("", 3) = " "
StringUtil.leftPad("bat", 3) = "bat"
StringUtil.leftPad("bat", 5) = " bat"
StringUtil.leftPad("bat", 1) = "bat"
StringUtil.leftPad("bat", -1) = "bat"
str - string to be modifiedsize - size that includes letter for paddingnull if null String inputpublic static String leftPad(String str, int size, char padChar)
StringUtil.leftPad(null, *, *) = null
StringUtil.leftPad("", 3, 'z') = "zzz"
StringUtil.leftPad("bat", 3, 'z') = "bat"
StringUtil.leftPad("bat", 5, 'z') = "zzbat"
StringUtil.leftPad("bat", 1, 'z') = "bat"
StringUtil.leftPad("bat", -1, 'z') = "bat"
str - string to be modifiedsize - size that includes letter for paddingpadChar - letter to fill innull if null String inputpublic static String leftPad(String str, int size, String padStr)
StringUtil.leftPad(null, *, *) = null
StringUtil.leftPad("", 3, "z") = "zzz"
StringUtil.leftPad("bat", 3, "yz") = "bat"
StringUtil.leftPad("bat", 5, "yz") = "yzbat"
StringUtil.leftPad("bat", 8, "yz") = "yzyzybat"
StringUtil.leftPad("bat", 1, "yz") = "bat"
StringUtil.leftPad("bat", -1, "yz") = "bat"
StringUtil.leftPad("bat", 5, null) = " bat"
StringUtil.leftPad("bat", 5, "") = " bat"
str - string to be modifiedsize - size that includes letter for paddingpadStr - letter to fill innull if null String inputpublic static String leftTrim(String str)
str - input stringStringUtils.trimLeadingWhitespace(String)public static String newLineToSpace(String str)
str - the String to convert@Deprecated public static String null2str(String org)
nullToString(String)org - original stringpublic static String nullToString(String org)
org - original string@Deprecated public static String null2str(String org, String converted)
nullToString(String, String)org - original stringconverted - converted stringpublic static String nullToString(String str, String defaultStr)
str - original stringdefaultStr - converted stringpublic static String nullToEmpty(String str)
str - the String to check@Deprecated public static String numberFormat(double d, String format)
d - the double value to convertformat - decimal format for conversion@Deprecated public static String numberFormat(float f, String format)
f - the float value to convertformat - decimal format for conversion@Deprecated public static String numberFormat(int i, String format)
i - the int value to convertformat - decimal format for conversion@Deprecated public static String numberFormat(long l, String format)
l - the long value to convertformat - decimal format for conversion@Deprecated public static String numberFormat(short s, String format)
s - the short value to convertformat - decimal format for conversion@Deprecated public static Object nvl(Object inputObject, Object defaultObject)
nullToObject(Object, Object)inputObject - the Object to checkdefaultObject - the default Objectpublic static Object nullToObject(Object obj, Object defaultObj)
obj - the Object to checkdefaultObj - the default Object@Deprecated public static String nvl(String inputString, String defaultString)
nullToString(String, String)inputString - the String to checkdefaultString - the default String@Deprecated public static String padding(int size, char padChar)
repeat(int, char)size - the length to pad topadChar - the character to pad withpublic static String repeat(int size, char ch)
size - the number of repeatch - the character to repeatpublic static String pathClean(String path)
path - the path String to normalizepublic static boolean pathEquals(String path1, String path2)
path1 - the path String to comparepath2 - the path String to compare@Deprecated public static String removeAll(String str, String charsToDelete)
deleteAny(String, String)str - input stringcharsToDelete - string to be deletedStringUtils.deleteAny(String, String)@Deprecated public static String removeChar(String str, char remove)
deleteAny(String, char)str - the source String to searchremove - the char to search for and remove@Deprecated public static String removeCharAll(String str)
deleteAny(String, char[])str - the source String to search@Deprecated public static String removeCharAll(String str, char[] remove)
deleteAny(String, char[])str - the source String to searchremove - chars to search for (case insensitive) and removepublic static String deleteAny(String str, String charsToDelete)
str - input stringcharsToDelete - string to be deletedStringUtils.deleteAny(String, String)public static String deleteAny(String str, char[] charsToDelete)
str - the source String to searchcharsToDelete - chars to search for (case insensitive) and removepublic static String deleteAny(String str, char charToDelete)
str - the source String to searchcharToDelete - the char to search for and removepublic static String deleteMatches(String str, String subStr)
str - input stringsubStr - string to be deletedStringUtils.delete(String, String)public static String deleteFirstMatches(String str, String deletedStr)
StringUtil.deleteFirstMatches("pass*word", "*") = "password"
str - original StringdeletedStr - String to be deletedpublic static String removeWhitespace(String str)
str - input stringStringUtils.trimAllWhitespace(String)@Deprecated public static String replace(String str, String replacedStr, String replacement)
StringUtil.replace("work$id", "$", ".") = "work.id"
str - original StringreplacedStr - to be replaced Stringreplacement - replace Stringpublic static String replaceAll(String str, String regex, String replacement)
str - input stringregex - regular expressionreplacement - given replacementString.replaceAll(String, String)public static String replaceFirst(String src, String regex, String replacement)
src - input stringregex - regular expressionreplacement - given replacementString.replaceFirst(String, String)public static String replaceLast(String str, String regex, String replacement)
str - input stringregex - regular expressionreplacement - given replacement@Deprecated public static String replacePattern(String str, String replacedStr, String replacement)
replaceAll(String, String, String)str - text to search and replace in, may be nullreplacedStr - the String to search for, may be nullreplacement - the String to replace it with, may be null@Deprecated public static String replaceHtmlEscape(String str)
htmlEscape(String)str - the (unescaped) input stringHtmlUtils.htmlEscape(String)public static String htmlEscape(String input)
input - the (unescaped) input stringHtmlUtils.htmlEscape(String)@Deprecated public static String removeEscapeChar(String str)
htmlUnescape(String)str - the (escaped) input stringHtmlUtils.htmlUnescape(String)public static String htmlUnescape(String input)
input - the (escaped) input stringHtmlUtils.htmlUnescape(String)public static String reverse(String str)
str - the String to reverse, may be nullnull if null String inputpublic static String right(String str, int size)
str - the String to get the rightmost characters from, may be nullsize - the length of the required Stringpublic static String rightPad(String str, int size)
StringUtil.rightPad(null, *) = null
StringUtil.rightPad("", 3) = " "
StringUtil.rightPad("bat", 3) = "bat"
StringUtil.rightPad("bat", 5) = "bat "
StringUtil.rightPad("bat", 1) = "bat"
StringUtil.rightPad("bat", -1) = "bat"
str - string to be modifiedsize - size that includes letter for paddingnull if null String inputpublic static String rightPad(String str, int size, char padChar)
StringUtil.rightPad(null, *, *) = null
StringUtil.rightPad("", 3, 'z') = "zzz"
StringUtil.rightPad("bat", 3, 'z') = "bat"
StringUtil.rightPad("bat", 5, 'z') = "batzz"
StringUtil.rightPad("bat", 1, 'z') = "bat"
StringUtil.rightPad("bat", -1, 'z') = "bat"
str - string to be modifiedsize - size that includes letter for paddingpadChar - letter for paddingnull if null String inputpublic static String rightPad(String str, int size, String padStr)
StringUtil.rightPad(null, *, *) = null
StringUtil.rightPad("", 3, "z") = "zzz"
StringUtil.rightPad("bat", 3, "yz") = "bat"
StringUtil.rightPad("bat", 5, "yz") = "batyz"
StringUtil.rightPad("bat", 8, "yz") = "batyzyzy"
StringUtil.rightPad("bat", 1, "yz") = "bat"
StringUtil.rightPad("bat", -1, "yz") = "bat"
StringUtil.rightPad("bat", 5, null) = "bat "
StringUtil.rightPad("bat", 5, "") = "bat "
str - the String to pad out, may be nullsize - the size to pad topadStr - the String to pad with, null or empty treated as single spacenull if null String inputpublic static String rightTrim(String str)
str - input stringStringUtils.trimTrailingWhitespace(String)@Deprecated public static String[] split(String str, char separator)
tokenizeToStringArray(String, char)str - the String to parseseparator - the character used as the delimiter@Deprecated public static String splitHead(String str, int size)
left(String, int)str - input stringsize - length of string@Deprecated public static String splitHeadWithEllipsis(String str, int len)
abbreviateFromLeft(String, int)str - the String to get the leftmost characters from, may be nulllen - the length of the required Stringpublic static String abbreviateFromLeft(String str, int size)
str - the String to get the leftmost characters from, may be nullsize - the length of the required String@Deprecated public static String splitTail(String str, int size)
right(String, int)str - input stringsize - length of string@Deprecated public static String splitTailWithEllipsis(String str, int len)
abbreviateFromRight(String, int)str - the String to get the rightmost characters from, may be nulllen - the length of the required Stringpublic static String abbreviateFromRight(String str, int size)
str - the String to get the rightmost characters from, may be nullsize - the length of the required String@Deprecated public static int string2integer(String str)
StringUtil.string2integer('14') = 14
str - string representation of a number@Deprecated public static BigDecimal stringToBigDecimal(String str)
str - the String value to convert@Deprecated public static BigDecimal stringToBigDecimal(String str, int pos, int len)
str - the String value to convertpos - the start positionlen - the length of str from pospublic static String stringToHex(String str)
str - the String to convert@Deprecated public static int stringToNumn(String str)
str - the String to convert@Deprecated public static int stringToNumn(String str, int pos, int len)
str - the String value to convertpos - the start positionlen - the length of str from pospublic static String toBusinessNoPattern(String str)
str - the String value to convertpublic static String[] tokenizeToStringArray(String str)
str - the String to parsepublic static String[] tokenizeToStringArray(String str, char delimeter)
str - the String to parsedelimeter - the character used as the delimiterpublic static String[] tokenizeToStringArray(String str, String delimiter)
str - the String to parsedelimiter - the String used as the delimiterpublic static String[] tokenizeToStringArray(String str, String delimeter, boolean trimTokens, boolean ignoreEmptyTokens)
str - the String to parsedelimeter - the character used as the delimitertrimTokens - trim every tokens of arrayignoreEmptyTokens - ignore empty tokens@Deprecated public static String toLowercase(String str)
toLowerCaseFirstLetter(String)str - input stringpublic static String toLowerCaseFirstLetter(String str)
str - input stringpublic static String toSocialSecuNoPattern(String str)
str - the String value to convertpublic static String toTelephoneNumberFormat(String str)
String actual = StringUtil.toTelephoneNumberFormat("032-123-4567"); // 032-123-4567
String actual = StringUtil.toTelephoneNumberFormat("021234567"); // 02-123-4567
String actual = StringUtil.toTelephoneNumberFormat("0212345678"); // 02-1234-5678
String actual = StringUtil.toTelephoneNumberFormat("1234567"); // 123-4567
str - the String value to convert@Deprecated public static String toUpperCase(String str)
toUpperCaseFirstLetter(String)str - input stringpublic static String toUpperCaseFirstLetter(String str)
str - input stringpublic static String toZipCodePattern(String str)
str - the String value to convert@Deprecated public static String trim(String origString, String trimString)
deleteFirstMatches(String, String)
StringUtil.trim("pass*word", "*") = "password"
origString - original StringtrimString - String to be trimmedpublic static boolean trimEquals(String str1, String str2)
str1 - the first String, may be nullstr2 - the second String, may be nullpublic static String unqualify(String str)
str - input stringpublic static String unqualify(String str, char delimiter)
str - input stringdelimiter - the seperator characterpublic static String convertStringCharset(String str, String charset) throws UnsupportedEncodingException
str - target stringcharset - the name of a supported charsetUnsupportedEncodingException - throws un supported Encoding Exception@Deprecated public static boolean isNumeric(String str)
NumberUtils.isNumber(String)str - is number format string value@Deprecated public static boolean isFormattedString(String str, String regex)
isRegexPatternMatch(String, String)str - the String to check, may be nullregex - the pattern to check, may be nullpublic static boolean isRegexPatternMatch(String str, String pattern)
StringUtil.isRegexPatternMatch("aaaaab", "a*b") = true;
StringUtil.isRegexPatternMatch("cabbbb", "a*b") = false;
str - pattern to be checkedpattern - regular expression patterntruepublic static boolean isPatternMatching(String str, String pattern)
StringUtil.isPatternMatching("abc-def', "*-*") = true
StringUtil.isPatternMatching("abc", "*-*") = false
str - pattern to be checkedpattern - pattern Stringtruepublic static boolean isUserFormat(String str, String pattern)
StringUtil.isUserFormat("123-456", "###-###") = true;
StringUtil.isUserFormat("123.456", "###.###") = true;
str - string to be checkedpattern - user defined patterntruepublic static boolean isPatternInclude(String str, String param)
StringUtil.isPatternInclude("asdf@5456", "s") = true;
StringUtil.isPatternInclude("-", "s") = true;
StringUtil.isPatternInclude("한", "k") = true;
StringUtil.isPatternInclude("123가32", "k") = true;
StringUtil.isPatternInclude("asdfsdfsdf", "e") = true;
StringUtil.isPatternInclude("asdfs1dfsdf", "e") = true;
StringUtil.isPatternInclude("123123123", "n") = true;
StringUtil.isPatternInclude("asdfs1dfsdf", "n") = true;
str - string to be checkedparam - filter patterntruepublic static boolean isRegexPatternInclude(String str, String pattern)
StringUtil.isRegexPatternInclude("cabbbb", "a*b")) = true
str - string to be checkedpattern - regular expression patterntrueCopyright © 2018. All rights reserved.