Operations on {@link java.lang.String} that are{@code null} safe.
- IsEmpty/IsBlank - checks if a String contains text
- Trim/Strip - removes leading and trailing whitespace
- Equals - compares two strings null-safe
- startsWith - check if a String starts with a prefix null-safe
- endsWith - check if a String ends with a suffix null-safe
- IndexOf/LastIndexOf/Contains - null-safe index-of checks
- IndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut - index-of any of a set of Strings
- ContainsOnly/ContainsNone/ContainsAny - does String contains only/none/any of these characters
- Substring/Left/Right/Mid - null-safe substring extractions
- SubstringBefore/SubstringAfter/SubstringBetween - substring extraction relative to other strings
- Split/Join - splits a String into an array of substrings and vice versa
- Remove/Delete - removes part of a String
- Replace/Overlay - Searches a String and replaces one String with another
- Chomp/Chop - removes the last part of a String
- LeftPad/RightPad/Center/Repeat - pads a String
- UpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize - changes the case of a String
- CountMatches - counts the number of occurrences of one String in another
- IsAlpha/IsNumeric/IsWhitespace/IsAsciiPrintable - checks the characters in a String
- DefaultString - protects against a null input String
- Reverse/ReverseDelimited - reverses a String
- Abbreviate - abbreviates a string using ellipsis
- Difference - compares Strings and reports on their differences
- LevenshteinDistance - the number of changes needed to change one String into another
The {@code StringUtils} class defines certain words related toString handling.
- null - {@code null}
- empty - a zero-length string ( {@code ""})
- space - the space character ( {@code ' '}, char 32)
- whitespace - the characters defined by {@link Character#isWhitespace(char)}
- trim - the characters <= 32 as in {@link String#trim()}
{@code StringUtils} handles {@code null} input Strings quietly.That is to say that a {@code null} input will return {@code null}. Where a {@code boolean} or {@code int} is being returneddetails vary by method.
A side effect of the {@code null} handling is that a{@code NullPointerException} should be considered a bug in{@code StringUtils}.
Methods in this class give sample code to explain their operation. The symbol {@code *} is used to indicate any input including {@code null}.
#ThreadSafe#
@see java.lang.String
@since 1.0
@version $Id: StringUtils.java 1199894 2011-11-09 17:53:59Z ggregory $