public final class StringUtils
extends java.lang.Object
| 限定符和类型 | 方法和说明 |
|---|---|
static java.lang.String |
clearEmptyChar(java.lang.String text)
Clear empty char from String.
|
static boolean |
equals(java.lang.String s1,
java.lang.String s2)
Compare two nullable string.
|
static byte[] |
getBytes(java.lang.String value)
Get bytes with UTF_8 charset.
|
static boolean |
isBlank(java.lang.String value)
Checks if a String is whitespace, empty ("") or null.
|
static boolean |
isNotBlank(java.lang.String value)
Checks if a String is not empty (""), not null and not whitespace only.
|
static java.lang.String |
newStr(byte[] bytes)
New string with UTF_8 charset.
|
static java.lang.String |
repeat(char value,
int n)
Repeat.
|
static java.lang.String |
subString(java.lang.String value,
int start,
int end)
Gets a substring from the specified String avoiding exceptions.
|
static java.lang.String |
zeros(int n)
Repeat zero.
|
static java.lang.String |
zeroSuffix(java.lang.String orig,
int length)
Get formatted string with zero suffix.
|
public static java.lang.String newStr(byte[] bytes)
bytes - byte[]public static byte[] getBytes(java.lang.String value)
value - Stringpublic static boolean equals(java.lang.String s1,
java.lang.String s2)
s1 - Strings2 - Stringpublic static boolean isBlank(java.lang.String value)
Checks if a String is whitespace, empty ("") or null.
StringUtils.isBlank(null) = true
StringUtils.isBlank("") = true
StringUtils.isBlank(" ") = true
StringUtils.isBlank("bob") = false
StringUtils.isBlank(" bob ") = false
value - the String to check, may be nulltrue if the String is null, empty or whitespacepublic static boolean isNotBlank(java.lang.String value)
Checks if a String is not empty (""), not null and not whitespace only.
StringUtils.isNotBlank(null) = false
StringUtils.isNotBlank("") = false
StringUtils.isNotBlank(" ") = false
StringUtils.isNotBlank("bob") = true
StringUtils.isNotBlank(" bob ") = true
value - the String to check, may be nulltrue if the String is not empty and not null and not whitespacepublic static java.lang.String subString(java.lang.String value,
int start,
int end)
value - the String to get the substring from, may be nullstart - the position to start from, negative means count back from the end of the String
by this many charactersend - the position to end at (exclusive), negative means count back from the end of the
String by this many charactersnull if null String inputpublic static java.lang.String zeroSuffix(java.lang.String orig,
int length)
orig - original valuelength - formatted lengthpublic static java.lang.String clearEmptyChar(java.lang.String text)
StringUtils.clearEmptyChar(" tes t") = "test"
text - original textpublic static java.lang.String zeros(int n)
n - number of zerospublic static java.lang.String repeat(char value,
int n)
value - repeat valuen - repeat timesCopyright © 2019. All Rights Reserved.