public class StringUtil extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
formatBinarySize(long size)
long size to string
|
static int |
indexOf(String[] array,
String v)
Returns the index within this string array of the first occurrence of
the specified string.
|
static int |
indexOf(String str,
int ch,
int fromIndex,
int toIndex)
Returns the index within this string of the first occurrence of the
specified character, starting the search at the specified range.
|
static boolean |
isBlank(CharSequence cs)
Checks if a CharSequence is empty (""), null or whitespace only.
|
static boolean |
isEmpty(String s)
|
static boolean |
isNotBlank(CharSequence cs)
Checks if a CharSequence is not empty (""), not null and not whitespace only.
|
static boolean |
isNotEmpty(String s)
|
static String |
lowFirstKey(String key)
Turn the first character into an lower case.
|
static void |
swap(String[] values,
int a,
int b)
Wrap value in string array
|
static String |
timeToString(long t)
Time millis to String, like 1h:3s or 4m:1s
|
static String |
toPascalCase(String name)
Convert to camel case string.
|
static String |
uppFirstKey(String key)
Turn the first character into an upper case.
|
public static boolean isEmpty(String s)
s - string value to checktrue if null or String.length() is 0, otherwise
falsepublic static boolean isNotEmpty(String s)
s - string value to checktrue if String.length() greater than 0, otherwise
falsepublic static int indexOf(String[] array, String v)
If no such string occurs in this array, then -1 is returned.
array - array to searchv - the specify string-1 if the string does not occur.public static String uppFirstKey(String key)
32.key - a string to processorpublic static String lowFirstKey(String key)
32.key - a string to processorpublic static String toPascalCase(String name)
name - a string to processorpublic static void swap(String[] values, int a, int b)
values - the array to warpa - from indexb - to indexpublic static boolean isBlank(CharSequence cs)
cs - the CharSequence to check, may be nulltrue if the CharSequence is null, empty or whitespace onlypublic static boolean isNotBlank(CharSequence cs)
cs - the CharSequence to check, may be nulltrue if the CharSequence is
not empty and not null and not whitespace onlypublic static String formatBinarySize(long size)
size - file size in bytespublic static String timeToString(long t)
t - time millispublic static int indexOf(String str, int ch, int fromIndex, int toIndex)
If a character with value ch occurs in the
character sequence represented by this String
object at an index no smaller than fromIndex, then
the index of the first such occurrence is returned. For values
of ch in the range from 0 to 0xFFFF (inclusive),
this is the smallest value k such that:
is true. For other values of(this.charAt(k) == ch)&&(k >= fromIndex)
ch, it is the
smallest value k such that:
is true. In either case, if no such character occurs in this string at or after position(this.codePointAt(k) == ch)&&(k >= fromIndex)
fromIndex, then
-1 is returned.
There is no restriction on the value of fromIndex. If it
is negative, it has the same effect as if it were zero: this entire
string may be searched. If it is greater than the length of this
string, it has the same effect as if it were equal to the length of
this string: -1 is returned.
All indices are specified in char values
(Unicode code units).
str - not nullch - a character (Unicode code point).fromIndex - the index to start the search from.toIndex - the high endpoint (exclusive) of the search end.fromIndex, or -1
if the character does not occur.Copyright © 2023. All rights reserved.