public final class StringUtils extends Object
The StringUtils class provides static methods that helps make string manipulation easy. The primary functionality it is meant to provide is the ability to split a string into a string array based on a given delimiter. This functionality is meant to take the place of the split(String) and split(String, int) method that was introduced in J2SE-1.4. Please note, however, that the splitting performed by this class simply splits the string based on the delimiter and does not perform any regular expression matching like the split methods provided in J2SE-1.4.
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
contains(String string,
String target)
Returns whether the first parameter contains the second parameter.
|
static String |
replaceAll(String string,
String target,
String replace)
Returns the string resulting from replacing all occurrences of the target
with the replace string.
|
static String |
replaceAllIgnoreCase(String string,
String target,
String replace)
Returns the string resulting from replacing all occurrences of the target
with the replace string.
|
static String |
replaceFirst(String string,
String target,
String replace)
Returns the string resulting from replacing the first occurrences of the
target with the replace string.
|
static String[] |
split(String string,
char character) |
static String[] |
split(String string,
String delimiter) |
static String[] |
split(String string,
String delimiter,
int limit) |
static String[] |
splitOnSpace(String string) |
static String |
splitSubstring(String string,
String delimiter,
int pos) |
static String |
xmlDecode(String string) |
static String |
xmlEncode(String string) |
public static boolean contains(String string, String target)
string
- must not be .
target
- must not be null.
public static String replaceAll(String string, String target, String replace)
string
- the start string. Must not be null
.target
- the target to search for in the start string. Must not be
null
.replace
- the replacement string to substitute when the target is found.
Must not be null
.null
. If target is not
found in the given string, then the result will be the entire
input string.public static String replaceAllIgnoreCase(String string, String target, String replace)
string
- the start string. Must not be null
.target
- the target to search for in the start string. Must not be
null
.replace
- the replacement string to substitute when the target is found.
Must not be null
.null
. If target is not
found in the given string, then the result will be the entire
input string.but case insensitive
public static String replaceFirst(String string, String target, String replace)
string
- the start string. Must not be null
.target
- the target to search for in the start string. Must not be
null
.replace
- the replacement string to substitute when the target is found.
Must not be null
.null
. If target is not
found in the given string, then the result will be the entire
input string.Copyright © 2004–2020 Eclipse Foundation. All rights reserved.