Org.apache.commons.lang
Class StringUtils
Java.lang.Object
Org.apache.commons.lang.StringUtils
stringutilsextends Object
Operations on that is String
null
safe.
- Isempty/isblank -Checks if a String contains text
- Trim/strip -removes leading and trailing whitespace
- Equals -Compares 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 to 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
- levensteindistance -The number of changes needed to change one String into another
The StringUtils
class defines certain words related to String handling.
- Null-
null
- Empty-a zero-length string (
""
)
- Space-the space character (
‘ ‘
, char 32)
- Whitespace-the characters defined by
Character.isWhitespace(char)
- Trim-the characters <=
String.trim()
StringUtils
Handles null
input Strings quietly. That's to say. A null
input would return null
. Where a boolean
or is int
being returned details vary by method.
A side effect of the null
handling is a NullPointerException
should being considered a bug in StringUtils
(except for deprecated methods).
Methods in this class give the sample code to explain their operation. The symbol is *
used to indicate any input including null
.
Translation: Google
Org.apache.commons.lang
class StringUtils
Org.apache.commons.lang.StringUtils
public class StringUtils Extended Object
the action String
to do this is a null
safe.
- Isempty/isblank -Check whether a string contains text
- Trim/Remove -Remove leading and trailing blanks
- equals -Comparison of two invalid strings
- StartsWith -Check whether a string begins with a prefix of NULL
- EndsWith -Check whether a string ends with a suffix of null
- Indexof/lastindexof/contains -Check for invalid indexes
- indexofany/lastindexofany/indexofanybut/lastindexofanybut -index-any set of strings
- Containsonly/containsnone/containsany -is a string containing only/none/any of these characters
- substring/Left/right/medium -0 Safe substring extraction
- Substringbefore/substringafter/substringbetween -substring extraction relative to other strings
- Split/Connect -Splits a string into an array of substrings and vice versa
- Delete/delete -Delete part of string
- Replace/overwrite -Search for a string and replace it with another string
- Chomp/chop -Delete The last part of the string
- left keyboard/Right keyboard/center/Repeat - fill string
- uppercase/lowercase/swapcase/capitalize/uncapitalize -Change Case of String
- countmatches -Count the occurrences of another string
- isalpha/isnumeric/iswhitespace/isasciiprintable -Check the characters in the string
- defaultstring -Prevent null input string
- reverse/reversedelimited -Reverse String
- Abbreviations -use ellipses to abbreviate strings
- difference -Compare strings and report differences
- levensteindistance -Change the number of changes required to change one string to another
in the StringUtils
class defines some words with string processing.
- Null value-
null
- null-a 0-length string (
""
)
- spaces-Empty characters (
‘ ‘
Char)
- Spaces-by ... The defined characters
Character.isWhitespace(char)
- Trim-Characters in <= 32
String.trim()
StringUtils
null
quietly to processing The input string. This means that one null
input will be returned null
. the boolean
int
details of where or are returning are different depending on the method.
a side effect null
of treatment is a NullPointerException
should be considered a mistake StringUtils
(except for deprecated methods).
The methods in this class give sample code to explain their operation. the symbol *
is used to indicate any input that is included null
.
Checks if the string is empty
Isnotempty The space parameter as well, Isnotblank excludes the space argument
Isnoneempty can add multiple parameters Isnoneblank can add multiple parameters, exclude the space parameter
Remove whitespace before and after a string
Trim/strip
Comparison of two strings for equality
Equals
Checks whether a string starts with a null prefix
StartsWith
Checks if the string ends with a null suffix
Checks if the string contains a specific character
Indexof/lastindexof/contains
JAVA StringUtils Tool Class