|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectcom.greenpineyu.fel.common.StringUtils
public class StringUtils
| 字段摘要 | |
|---|---|
static int |
INDEX_NOT_FOUND
Represents a failed index search. |
| 构造方法摘要 | |
|---|---|
StringUtils()
|
|
| 方法摘要 | |
|---|---|
static boolean |
equals(CharSequence cs1,
CharSequence cs2)
Compares two CharSequences, returning true if they are equal. |
static boolean |
isEmpty(CharSequence cs)
|
static boolean |
isNotEmpty(CharSequence cs)
Checks if a CharSequence is not empty ("") and not null. |
static String |
remove(String str,
char remove)
Removes all occurrences of a character from within the source string. |
static String |
replace(String text,
String searchString,
String replacement)
Replaces all occurrences of a String within another String. |
static String |
replace(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. |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
public static final int INDEX_NOT_FOUND
| 构造方法详细信息 |
|---|
public StringUtils()
| 方法详细信息 |
|---|
public static boolean isEmpty(CharSequence cs)
public static boolean isNotEmpty(CharSequence cs)
Checks if a CharSequence is not empty ("") and not null.
StringUtils.isNotEmpty(null) = false
StringUtils.isNotEmpty("") = false
StringUtils.isNotEmpty(" ") = true
StringUtils.isNotEmpty("bob") = true
StringUtils.isNotEmpty(" bob ") = true
cs - the CharSequence to check, may be null
true if the CharSequence is not empty and not null
public static String replace(String text,
String searchString,
String replacement)
Replaces all occurrences of a String within another String.
A null reference passed to this method is a no-op.
StringUtils.replace(null, *, *) = null
StringUtils.replace("", *, *) = ""
StringUtils.replace("any", null, *) = "any"
StringUtils.replace("any", *, null) = "any"
StringUtils.replace("any", "", *) = "any"
StringUtils.replace("aba", "a", null) = "aba"
StringUtils.replace("aba", "a", "") = "b"
StringUtils.replace("aba", "a", "z") = "zbz"
text - text to search and replace in, may be nullsearchString - the String to search for, may be nullreplacement - the String to replace it with, may be null
null if null String inputreplace(String text, String searchString, String replacement, int max)
public static String replace(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.
A null reference passed to this method is a no-op.
StringUtils.replace(null, *, *, *) = null
StringUtils.replace("", *, *, *) = ""
StringUtils.replace("any", null, *, *) = "any"
StringUtils.replace("any", *, null, *) = "any"
StringUtils.replace("any", "", *, *) = "any"
StringUtils.replace("any", *, *, 0) = "any"
StringUtils.replace("abaa", "a", null, -1) = "abaa"
StringUtils.replace("abaa", "a", "", -1) = "b"
StringUtils.replace("abaa", "a", "z", 0) = "abaa"
StringUtils.replace("abaa", "a", "z", 1) = "zbaa"
StringUtils.replace("abaa", "a", "z", 2) = "zbza"
StringUtils.replace("abaa", "a", "z", -1) = "zbzz"
text - text to search and replace in, may be nullsearchString - the String to search for, may be nullreplacement - the String to replace it with, may be nullmax - maximum number of values to replace, or -1 if no maximum
null if null String input
public static String remove(String str,
char remove)
Removes all occurrences of a character from within the source string.
A null source string will return null.
An empty ("") source string will return the empty string.
StringUtils.remove(null, *) = null
StringUtils.remove("", *) = ""
StringUtils.remove("queued", 'u') = "qeed"
StringUtils.remove("queued", 'z') = "queued"
str - the source String to search, may be nullremove - the char to search for and remove, may be null
null if null String input
public static boolean equals(CharSequence cs1,
CharSequence cs2)
Compares two CharSequences, returning true if they are equal.
nulls are handled without exceptions. Two null
references are considered to be equal. The comparison is case sensitive.
StringUtils.equals(null, null) = true
StringUtils.equals(null, "abc") = false
StringUtils.equals("abc", null) = false
StringUtils.equals("abc", "abc") = true
StringUtils.equals("abc", "ABC") = false
cs1 - the first CharSequence, may be nullcs2 - the second CharSequence, may be null
true if the CharSequences are equal, case sensitive, or
both nullString.equals(Object)
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||