public class StringTools
extends java.lang.Object
Constructor and Description |
---|
StringTools() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
clean(java.lang.String s)
Cuts out HTML tags, reduces repeating spaces, and trims the input string.
|
static java.util.List<java.lang.String> |
findAllMatch(java.lang.String in,
java.lang.String pattern,
int group)
Finds all matching part of a pattern in a string, then returns their one
group in a list.
|
static java.lang.String |
findFirstMatch(java.lang.String in,
java.lang.String pattern,
int group)
Finds the first matching part of a pattern in a string and returns the
specified group.
|
static java.lang.String |
formatDataSize(long bytes)
Transforms a data size in bytes to a readable text which includes the unit.
|
static java.lang.String |
formatNanoTime(long time,
boolean showMicro,
boolean showNano)
Transforms a time in nanoseconsds to a readable text.
|
static java.lang.String |
lpad(java.lang.String s,
int n,
char c)
Pads a text from left to the specified length with the specified character.
|
static java.lang.String |
rpad(java.lang.String s,
int n,
char c)
Pads a text from right to the specified length with the specified character.
|
public static java.lang.String clean(java.lang.String s)
s
- Input text.public static java.lang.String findFirstMatch(java.lang.String in, java.lang.String pattern, int group)
in
- Input text.pattern
- Pattern.group
- Needed group.public static java.util.List<java.lang.String> findAllMatch(java.lang.String in, java.lang.String pattern, int group)
in
- Input text.pattern
- Pattern.group
- Needed group.public static java.lang.String formatDataSize(long bytes)
bytes
- Number to format.public static java.lang.String formatNanoTime(long time, boolean showMicro, boolean showNano)
time
- Time to format.showMicro
- Include microseconds in the text?showNano
- Include nanoseconds in the text?public static java.lang.String lpad(java.lang.String s, int n, char c)
s
- Input text.n
- Needed length.c
- Fill character.public static java.lang.String rpad(java.lang.String s, int n, char c)
s
- Input text.n
- Needed length.c
- Fill character.