Static utility methods for null-safe String operations.
CharSequence for inputs over String whenever possible, so that all implementations (e.g. StringBuffer, StringBuilder, CharBuffer)
can benefit.
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static String | capitalize(String str)
Capitalizes a string changing its first character to title case as per |
| public static String | capitalizeFully(String text, Locale locale)
Converts every word in the given text to title case (first letter upper-cased via |
| public static boolean | isBlank(CharSequence cs)
Returns |
| public static boolean | Returns: true if char sequence is empty or null, false otherwisechar sequence to test cs)Checks if the given char sequence is either null or empty. |
| public static int | Returns: length of stringstring cs)Gets the given char sequence's length or |
| public static String | Returns: modified inputthe character sequence to remove from cs, CharSequence the character sequence to remove remove)Removes all occurrences of character sequence |
| public static String | |
| public static String | |
| public static boolean | Returns: true if neither argument is null and str starts with prefix ignoring casestring to test, may be str, String nullprefix to look for, may be prefix)nullChecks case-insensitively whether the given string starts with the given prefix. |
| public static String | toTitleCase(String str)
Converts a string to "title case", a type of capitalization in which the first letter of a word (following an underscore) except in position 0 is capitalized, underscores are removed, and the rest of the letters are lower-case. |
| public static String | trimToNull(CharSequence cs)
Returns the given char sequence trimmed or |
| StringUtil | back to summary |
|---|---|
| private StringUtil() | |
| capitalize | back to summary |
|---|---|
| public static String capitalize(String str) Capitalizes a string changing its first character to title case as per | |
| capitalizeFully | back to summary |
|---|---|
| public static String capitalizeFully(String text, Locale locale) Converts every word in the given text to title case (first letter upper-cased via | |
| isBlank | back to summary |
|---|---|
| public static boolean isBlank(CharSequence cs) Returns | |
| isEmpty | back to summary |
|---|---|
| public static boolean isEmpty(CharSequence cs) Checks if the given char sequence is either null or empty.
| |
| length | back to summary |
|---|---|
| public static int length(CharSequence cs) Gets the given char sequence's length or
| |
| remove | back to summary |
|---|---|
| public static String remove(CharSequence cs, CharSequence remove) Removes all occurrences of character sequence
| |
| repeat | back to summary |
|---|---|
| public static String repeat(String str, int count) Returns a string whose value is the concatenation of the given string repeated | |
| replace | back to summary |
|---|---|
| public static String replace(String text, CharSequence searchString, CharSequence replacement) | |
| startsWithIgnoreCase | back to summary |
|---|---|
| public static boolean startsWithIgnoreCase(String str, String prefix) Checks case-insensitively whether the given string starts with the given prefix. | |
| toTitleCase | back to summary |
|---|---|
| public static String toTitleCase(String str) Converts a string to "title case", a type of capitalization in which the first letter of a word (following an underscore) except in position 0 is capitalized, underscores are removed, and the rest of the letters are lower-case. | |
| trimToNull | back to summary |
|---|---|
| public static String trimToNull(CharSequence cs) Returns the given char sequence trimmed or | |