Java org.apache.commons.lang StringUtils fields, constructors, methods, implement or subclass

Example usage for Java org.apache.commons.lang StringUtils fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for org.apache.commons.lang StringUtils.

The text is from its open source code.

Subclass

org.apache.commons.lang.StringUtils has subclasses.
Click this link to see all its subclasses.

Field

StringEMPTY
The empty String "".
intINDEX_NOT_FOUND
Represents a failed index search.

Constructor

StringUtils()

StringUtils instances should NOT be constructed in standard programming.

Method

Stringabbreviate(String str, int offset, int maxWidth)

Abbreviates a String using ellipses.

Stringabbreviate(String str, int maxWidth)

Abbreviates a String using ellipses.

StringabbreviateMiddle(String str, String middle, int length)

Abbreviates a String to the length passed, replacing the middle characters with the supplied replacement String.

Stringcapitalize(String str)

Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .

Stringcenter(String str, int size, char padChar)

Centers a String in a larger String of size size.

Stringcenter(String str, int size, String padStr)

Centers a String in a larger String of size size.

Stringcenter(String str, int size)

Centers a String in a larger String of size size using the space character (' ').

Stringchomp(String str, String separator)

Removes separator from the end of str if it's there, otherwise leave it alone.

Stringchomp(String str)

Removes one newline from end of a String if it's there, otherwise leave it alone.

Stringchop(String str)

Remove the last character from a String.

booleancontains(String str, char searchChar)

Checks if String contains a search character, handling null.

booleancontains(String str, String searchStr)

Checks if String contains a search String, handling null.

booleancontainsAny(String str, char[] searchChars)

Checks if the String contains any character in the given set of characters.

booleancontainsAny(String str, String searchChars)

Checks if the String contains any character in the given set of characters.

booleancontainsIgnoreCase(String str, String searchStr)

Checks if String contains a search String irrespective of case, handling null.

booleancontainsNone(String str, char[] searchChars)

Checks that the String does not contain certain characters.

booleancontainsNone(String str, String invalidChars)

Checks that the String does not contain certain characters.

booleancontainsOnly(String str, char[] valid)

Checks if the String contains only certain characters.

booleancontainsOnly(String str, String validChars)

Checks if the String contains only certain characters.

intcountMatches(String str, String sub)

Counts how many times the substring appears in the larger String.

StringdefaultIfBlank(String str, String defaultStr)

Returns either the passed in String, or if the String is whitespace, empty ("") or null, the value of defaultStr.

StringdefaultIfEmpty(String str, String defaultStr)

Returns either the passed in String, or if the String is empty or null, the value of defaultStr.

StringdefaultString(String str)

Returns either the passed in String, or if the String is null, an empty String ("").

StringdefaultString(String str, String defaultStr)

Returns either the passed in String, or if the String is null, the value of defaultStr.

StringdeleteWhitespace(String str)

Deletes all whitespaces from a String as defined by Character#isWhitespace(char) .

Stringdifference(String str1, String str2)

Compares two Strings, and returns the portion where they differ.

booleanendsWith(String str, String suffix)

Check if a String ends with a specified suffix.

booleanendsWithAny(String string, String[] searchStrings)

Check if a String ends with any of an array of specified strings.

booleanendsWithIgnoreCase(String str, String suffix)

Case insensitive check if a String ends with a specified suffix.

booleanequals(String str1, String str2)

Compares two Strings, returning true if they are equal.

booleanequalsIgnoreCase(String str1, String str2)

Compares two Strings, returning true if they are equal ignoring the case.

StringgetCommonPrefix(String[] strs)

Compares all Strings in an array and returns the initial sequence of characters that is common to all of them.

intgetLevenshteinDistance(String s, String t)

Find the Levenshtein distance between two Strings.

intindexOf(String str, char searchChar)

Finds the first index within a String, handling null.

intindexOf(String str, String searchStr)

Finds the first index within a String, handling null.

intindexOf(String str, char searchChar, int startPos)

Finds the first index within a String from a start position, handling null.

intindexOf(String str, String searchStr, int startPos)

Finds the first index within a String, handling null.

intindexOfAny(String str, char[] searchChars)

Search a String to find the first index of any character in the given set of characters.

intindexOfAny(String str, String searchChars)

Search a String to find the first index of any character in the given set of characters.

intindexOfAny(String str, String[] searchStrs)

Find the first index of any of a set of potential substrings.

intindexOfAnyBut(String str, char[] searchChars)

Search a String to find the first index of any character not in the given set of characters.

intindexOfAnyBut(String str, String searchChars)

Search a String to find the first index of any character not in the given set of characters.

intindexOfDifference(String str1, String str2)

Compares two Strings, and returns the index at which the Strings begin to differ.

intindexOfDifference(String[] strs)

Compares all Strings in an array and returns the index at which the Strings begin to differ.

intindexOfIgnoreCase(String str, String searchStr)

Case in-sensitive find of the first index within a String.

intindexOfIgnoreCase(String str, String searchStr, int startPos)

Case in-sensitive find of the first index within a String from the specified position.

booleanisAllLowerCase(String str)

Checks if the String contains only lowercase characters.

booleanisAllUpperCase(String str)

Checks if the String contains only uppercase characters.

booleanisAlpha(String str)

Checks if the String contains only unicode letters.

booleanisAlphanumeric(String str)

Checks if the String contains only unicode letters or digits.

booleanisAlphanumericSpace(String str)

Checks if the String contains only unicode letters, digits or space ( ' ').

booleanisAlphaSpace(String str)

Checks if the String contains only unicode letters and space (' ').

booleanisAsciiPrintable(String str)

Checks if the string contains only ASCII printable characters.

booleanisBlank(String str)

Checks if a String is whitespace, empty ("") or null.

booleanisEmpty(String str)

Checks if a String is empty ("") or null.

booleanisNotBlank(String str)

Checks if a String is not empty (""), not null and not whitespace only.

booleanisNotEmpty(String str)

Checks if a String is not empty ("") and not null.

booleanisNumeric(String str)

Checks if the String contains only unicode digits.

booleanisNumericSpace(String str)

Checks if the String contains only unicode digits or space ( ' ').

booleanisWhitespace(String str)

Checks if the String contains only whitespace.

Stringjoin(Object[] array, char separator)

Joins the elements of the provided array into a single String containing the provided list of elements.

Stringjoin(Object[] array, String separator)

Joins the elements of the provided array into a single String containing the provided list of elements.

Stringjoin(Iterator iterator, char separator)

Joins the elements of the provided Iterator into a single String containing the provided elements.

Stringjoin(Iterator iterator, String separator)

Joins the elements of the provided Iterator into a single String containing the provided elements.

Stringjoin(Collection collection, char separator)

Joins the elements of the provided Collection into a single String containing the provided elements.

Stringjoin(Collection collection, String separator)

Joins the elements of the provided Collection into a single String containing the provided elements.

Stringjoin(Object[] array)

Joins the elements of the provided array into a single String containing the provided list of elements.

Stringjoin(Object[] array, char separator, int startIndex, int endIndex)

Joins the elements of the provided array into a single String containing the provided list of elements.

Stringjoin(Object[] array, String separator, int startIndex, int endIndex)

Joins the elements of the provided array into a single String containing the provided list of elements.

intlastIndexOf(String str, char searchChar)

Finds the last index within a String, handling null.

intlastIndexOf(String str, String searchStr)

Finds the last index within a String, handling null.

intlastIndexOf(String str, char searchChar, int startPos)

Finds the last index within a String from a start position, handling null.

intlastIndexOf(String str, String searchStr, int startPos)

Finds the first index within a String, handling null.

intlastIndexOfAny(String str, String[] searchStrs)

Find the latest index of any of a set of potential substrings.

intlastIndexOfIgnoreCase(String str, String searchStr)

Case in-sensitive find of the last index within a String.

intlastOrdinalIndexOf(String str, String searchStr, int ordinal)

Finds the n-th last index within a String, handling null.

Stringleft(String str, int len)

Gets the leftmost len characters of a String.

StringleftPad(String str, int size)

Left pad a String with spaces (' ').

StringleftPad(String str, int size, char padChar)

Left pad a String with a specified character.

StringleftPad(String str, int size, String padStr)

Left pad a String with a specified String.

intlength(String str)
Gets a String's length or 0 if the String is null.
StringlowerCase(String str)

Converts a String to lower case as per String#toLowerCase() .

StringlowerCase(String str, Locale locale)

Converts a String to lower case as per String#toLowerCase(Locale) .

Stringmid(String str, int pos, int len)

Gets len characters from the middle of a String.

StringnormalizeSpace(String str)

Similar to http://www.w3.org/TR/xpath/#function-normalize -space

The function returns the argument string with whitespace normalized by using #trim(String) to remove leading and trailing whitespace and then replacing sequences of whitespace characters by a single space.

intordinalIndexOf(String str, String searchStr, int ordinal)

Finds the n-th index within a String, handling null.

Stringoverlay(String str, String overlay, int start, int end)

Overlays part of a String with another String.

Stringremove(String str, String remove)

Removes all occurrences of a substring from within the source string.

Stringremove(String str, char remove)

Removes all occurrences of a character from within the source string.

StringremoveEnd(String str, String remove)

Removes a substring only if it is at the end of a source string, otherwise returns the source string.

StringremoveEndIgnoreCase(String str, String remove)

Case insensitive removal of a substring if it is at the end of a source string, otherwise returns the source string.

StringremoveStart(String str, String remove)

Removes a substring only if it is at the begining of a source string, otherwise returns the source string.

StringremoveStartIgnoreCase(String str, String remove)

Case insensitive removal of a substring if it is at the begining of a source string, otherwise returns the source string.

Stringrepeat(String str, int repeat)

Repeat a String repeat times to form a new String.

Stringrepeat(String str, String separator, int repeat)

Repeat a String repeat times to form a new String, with a String separator injected each time.

Stringreplace(String text, String searchString, String replacement)

Replaces all occurrences of a String within another String.

Stringreplace(String text, String searchString, String replacement, int max)

Replaces a String with another String inside a larger String, for the first max values of the search String.

StringreplaceChars(String str, char searchChar, char replaceChar)

Replaces all occurrences of a character in a String with another.

StringreplaceChars(String str, String searchChars, String replaceChars)

Replaces multiple characters in a String in one go.

StringreplaceEach(String text, String[] searchList, String[] replacementList)

Replaces all occurrences of Strings within another String.

StringreplaceEachRepeatedly(String text, String[] searchList, String[] replacementList)

Replaces all occurrences of Strings within another String.

StringreplaceOnce(String text, String searchString, String replacement)

Replaces a String with another String inside a larger String, once.

Stringreverse(String str)

Reverses a String as per StrBuilder#reverse() .

StringreverseDelimited(String str, char separatorChar)

Reverses a String that is delimited by a specific character.

Stringright(String str, int len)

Gets the rightmost len characters of a String.

StringrightPad(String str, int size)

Right pad a String with spaces (' ').

StringrightPad(String str, int size, char padChar)

Right pad a String with a specified character.

StringrightPad(String str, int size, String padStr)

Right pad a String with a specified String.

String[]split(String str, char separatorChar)

Splits the provided text into an array, separator specified.

String[]split(String str, String separatorChars)

Splits the provided text into an array, separators specified.

String[]split(String str)

Splits the provided text into an array, using whitespace as the separator.

String[]split(String str, String separatorChars, int max)

Splits the provided text into an array with a maximum length, separators specified.

String[]splitByCharacterType(String str)

Splits a String by Character type as returned by java.lang.Character.getType(char).

String[]splitByCharacterTypeCamelCase(String str)

Splits a String by Character type as returned by java.lang.Character.getType(char).

String[]splitByWholeSeparator(String str, String separator, int max)

Splits the provided text into an array, separator string specified.

String[]splitByWholeSeparator(String str, String separator)

Splits the provided text into an array, separator string specified.

String[]splitByWholeSeparatorPreserveAllTokens(String str, String separator)

Splits the provided text into an array, separator string specified.

String[]splitByWholeSeparatorPreserveAllTokens(String str, String separator, int max)

Splits the provided text into an array, separator string specified.

String[]splitPreserveAllTokens(String str, char separatorChar)

Splits the provided text into an array, separator specified, preserving all tokens, including empty tokens created by adjacent separators.

String[]splitPreserveAllTokens(String str, String separatorChars)

Splits the provided text into an array, separators specified, preserving all tokens, including empty tokens created by adjacent separators.

String[]splitPreserveAllTokens(String str, String separatorChars, int max)

Splits the provided text into an array with a maximum length, separators specified, preserving all tokens, including empty tokens created by adjacent separators.

String[]splitPreserveAllTokens(String str)

Splits the provided text into an array, using whitespace as the separator, preserving all tokens, including empty tokens created by adjacent separators.

booleanstartsWith(String str, String prefix)

Check if a String starts with a specified prefix.

booleanstartsWithAny(String string, String[] searchStrings)

Check if a String starts with any of an array of specified strings.

booleanstartsWithIgnoreCase(String str, String prefix)

Case insensitive check if a String starts with a specified prefix.

Stringstrip(String str, String stripChars)

Strips any of a set of characters from the start and end of a String.

Stringstrip(String str)

Strips whitespace from the start and end of a String.

String[]stripAll(String[] strs)

Strips whitespace from the start and end of every String in an array.

String[]stripAll(String[] strs, String stripChars)

Strips any of a set of characters from the start and end of every String in an array.

StringstripEnd(String str, String stripChars)

Strips any of a set of characters from the end of a String.

StringstripStart(String str, String stripChars)

Strips any of a set of characters from the start of a String.

StringstripToEmpty(String str)

Strips whitespace from the start and end of a String returning an empty String if null input.

StringstripToNull(String str)

Strips whitespace from the start and end of a String returning null if the String is empty ("") after the strip.

Stringsubstring(String str, int start, int end)

Gets a substring from the specified String avoiding exceptions.

Stringsubstring(String str, int start)

Gets a substring from the specified String avoiding exceptions.

StringsubstringAfter(String str, String separator)

Gets the substring after the first occurrence of a separator.

StringsubstringAfterLast(String str, String separator)

Gets the substring after the last occurrence of a separator.

StringsubstringBefore(String str, String separator)

Gets the substring before the first occurrence of a separator.

StringsubstringBeforeLast(String str, String separator)

Gets the substring before the last occurrence of a separator.

StringsubstringBetween(String str, String open, String close)

Gets the String that is nested in between two Strings.

StringsubstringBetween(String str, String tag)

Gets the String that is nested in between two instances of the same String.

String[]substringsBetween(String str, String open, String close)

Searches a String for substrings delimited by a start and end tag, returning all matching substrings in an array.

StringswapCase(String str)

Swaps the case of a String changing upper and title case to lower case, and lower case to upper case.

Stringtrim(String str)

Removes control characters (char <= 32) from both ends of this String, handling null by returning null.

StringtrimToEmpty(String str)

Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null.

StringtrimToNull(String str)

Removes control characters (char <= 32) from both ends of this String returning null if the String is empty ("") after the trim or if it is null.

Stringuncapitalize(String str)

Uncapitalizes a String changing the first letter to title case as per Character#toLowerCase(char) .

StringupperCase(String str)

Converts a String to upper case as per String#toUpperCase() .

StringupperCase(String str, Locale locale)

Converts a String to upper case as per String#toUpperCase(Locale) .