@Immutable
public final class StringUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
isNullOrEmpty(java.lang.String string)
Returns
true if the given string is null or is the empty string. |
static java.lang.String |
padLeft(java.lang.String value,
int minLength)
Pads a given string on the left with leading 0's up the length.
|
static java.lang.String |
padStart(java.lang.String string,
int minLength,
char padChar)
Returns a string, of length at least
minLength , consisting of string prepended
with as many copies of padChar as are necessary to reach that length. |
public static java.lang.String padStart(java.lang.String string, int minLength, char padChar)
minLength
, consisting of string
prepended
with as many copies of padChar
as are necessary to reach that length. For example,
padStart("7", 3, '0')
returns "007"
padStart("2010", 3, '0')
returns "2010"
See Formatter
for a richer set of formatting capabilities.
This method was copied almost verbatim from Guava library method com.google.common.base.Strings#padStart(java.lang.String, int, char).
string
- the string which should appear at the end of the resultminLength
- the minimum length the resulting string must have. Can be zero or negative, in
which case the input string is always returned.padChar
- the character to insert at the beginning of the result until the minimum length
is reachedpublic static boolean isNullOrEmpty(java.lang.String string)
true
if the given string is null or is the empty string.
This method was copied verbatim from Guava library method com.google.common.base.Strings#isNullOrEmpty(java.lang.String).
string
- a string reference to checktrue
if the string is null or is the empty stringpublic static java.lang.String padLeft(java.lang.String value, int minLength)
value
- the string to padminLength
- the minimum length the resulting padded string must have. Can be zero or
negative, in which case the input string is always returned.