StringUtilclass offers more than 100 additional string utilities (and still growing). And each one is optimized for speed. Description of some methods follows, more details can be founded in JavaDoc and test cases.
replace()is one of the most missing functionality String needs. It doesn't use a regular expression, just simply replaces all founded substrings. Alternatively, there is a method that replaces just first or last occurrence of some substring:
remove(). The same can be done for removing a single character, as well as more characters at once:
StringUtilprovides methods for the detection of empty and blank strings. Empty strings are those that are either
nullor with zero-length;
isNotEmpty(). Blank strings are those that are either empty or that contains just whitespaces;
StringUtilalso may check several strings at once:
equals()offers safe compression of provided strings: it will not fail if one of the arguments is
null. Similarly, there is
equalsIgnoreCase()for checking two strings ignoring the characters case.
StringUtiloffers several split methods.
split(String src, String delimiter)splits a string into several parts (tokens) that are separated by a delimiter. A delimiter is always surrounded by two strings (tokens)! If there is no content between two delimiters, an empty string will be returned for that token. Therefore, the length of the returned array will always be
#delimiters + 1. This method is much, much faster than regexp variant
String.split()and just a bit faster than
splitc(String src, char d)and
splitc(String src, String d)splits a string into several parts (tokens) that are separated by delimiter characters. A delimiter may contain any number of characters, and it is always surrounded by two strings.
StringUtilprovides many missing
indexOfmethods. It is possible to scan just an inner part of a string, to ignore case while searching, to scan in both directions (from start or and of the string)... There are also more scanners, such:
endsWithIgnoreCase()are commonly needed methods.
intarray, where the first element is a substring index and the second element is founded position.
null), stripping (first or last characters from a string in a safe manner) and cutting (cut a string from the beginning or from the end up to the first occurrence of some substring, or cutting last or first words).
StringUtil. Please check the code or the JavaDocs :)