public class Strings extends Object
| Modifier and Type | Field and Description |
|---|---|
static String[] |
EMPTY_ARRAY |
static char |
SEPARATOR |
| Constructor and Description |
|---|
Strings() |
| Modifier and Type | Method and Description |
|---|---|
static String |
concat(String separator,
List<String> list) |
static String |
concat(String separator,
List<String> list,
int skip) |
static String |
convertFromJavaString(String javaString,
boolean useUnicode)
Mostly copied from
Properties.loadConvert(char[], int, int, char[]) |
static String |
convertToJavaString(String theString) |
static String |
convertToJavaString(String theString,
boolean useUnicode)
Mostly copied from
Properties.saveConvert(java.lang.String, boolean, boolean) |
static int |
countLineBreaks(CharSequence text)
Counts the number of line breaks.
|
static int |
countLineBreaks(CharSequence text,
int startInclusive,
int endExclusive)
Counts the number of line breaks.
|
static int |
countLines(String text)
Counts the number of lines where
separator is assumed to be the only valid line break sequence. |
static int |
countLines(String text,
char[] separator)
Counts the number of lines where the given separator sequence is the only valid line break sequence.
|
static int |
countLines(String text,
char[] separator,
int startInclusive,
int endExclusive)
Counts the number of lines between
startInclusive and endExclusive
where the given separator sequence is the only valid line break sequence. |
static String |
emptyIfNull(String s) |
static boolean |
equal(String literal,
String name) |
static boolean |
equalsIgnoreWhitespace(String left,
String right) |
static String |
getLeadingWhiteSpace(String original) |
static boolean |
isEmpty(String s) |
static String |
lastToken(String value,
String separator) |
static String |
newLine() |
static String |
notNull(Object o) |
static String |
pack(String[] strings) |
static String |
removeLeadingWhitespace(String indentationString) |
static String |
skipLastToken(String value,
String separator) |
static List<String> |
split(String value,
char delimiter)
Splits a string around matches of the given delimiter character.
|
static List<String> |
split(String value,
String delimiter)
Splits a string around matches of the given delimiter string.
|
static String |
toFirstLower(String s) |
static String |
toFirstUpper(String s) |
static char |
toHex(int nibble)
Copied from
Properties |
static <T> String |
toString(Collection<T> list,
com.google.common.base.Function<T,String> toString,
String delim) |
static CharSequence |
trimTrailingLineBreak(CharSequence s)
Assumes
'\r', '\n' or '\r\n' to be valid line breaks. |
static String[] |
unpack(String packed) |
static String |
wordWrap(String string,
int maxCharsPerLine) |
public static final String[] EMPTY_ARRAY
public static final char SEPARATOR
public static <T> String toString(Collection<T> list, com.google.common.base.Function<T,String> toString, String delim)
public static boolean isEmpty(String s)
public static String newLine()
public static String convertFromJavaString(String javaString, boolean useUnicode)
Properties.loadConvert(char[], int, int, char[])public static String convertToJavaString(String theString, boolean useUnicode)
Properties.saveConvert(java.lang.String, boolean, boolean)public static char toHex(int nibble)
Propertiespublic static List<String> split(String value, String delimiter)
This method works similar to String.split(String) but does not treat the delimiter
as a regular expression. This makes it perform better in most cases where this feature is not
necessary. Furthermore this implies that trailing empty segments will not be part of the
result.
For delimiters of length 1 it is preferred to use split(String, char) instead.
value - the string to splitdelimiter - the delimiting string (e.g. "::")null and the list does not contain any null values.NullPointerException - If the value or delimiter is nullpublic static List<String> split(String value, char delimiter)
This method works similar to String.split(String) but does not treat the delimiter
as a regular expression. This makes it perform better in most cases where this feature is not
necessary. Furthermore this implies that trailing empty segments will not be part of the
result.
value - the string to splitdelimiter - the delimiting character (e.g. '.' or ':')null and the list does not contain any null values.NullPointerException - If the value is nullString.split(String)public static String pack(String[] strings)
strings - array of strings, may not be null and may not contain any null values.NullPointerException - if the array of strings or any element in the array is nullpublic static int countLineBreaks(CharSequence text)
'\r', '\n' or '\r\n' to be valid line breaks.
This follows the semantics of the LineNumberReader.public static int countLineBreaks(CharSequence text, int startInclusive, int endExclusive)
'\r', '\n' or '\r\n' to be valid line breaks.
This follows the semantics of the LineNumberReader.public static CharSequence trimTrailingLineBreak(CharSequence s)
'\r', '\n' or '\r\n' to be valid line breaks.public static int countLines(String text)
separator is assumed to be the only valid line break sequence.
A string without any line separators returns 0 as the number of lines.public static int countLines(String text, char[] separator)
0 as the number of lines.public static int countLines(String text, char[] separator, int startInclusive, int endExclusive)
startInclusive and endExclusive
where the given separator sequence is the only valid line break sequence.
A string without any line separators in that range returns 0 as the number of lines.Copyright © 2015. All Rights Reserved.