public final class StringUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.util.List<java.lang.String> |
split(java.lang.String str,
char sep)
Splits a String around each occurence of the specified character.
|
static void |
split(java.lang.String str,
char sep,
java.util.List<java.lang.String> list)
Splits a String around each occurence of the specified character, and puts the result in the
given List.
|
static java.util.List<java.lang.String> |
splitLines(java.lang.String str)
Splits a String around each occurence of LF and CRLF.
|
static void |
splitLines(java.lang.String str,
java.util.List<java.lang.String> list)
Splits a String around each occurence of LF and CRLF, and puts the result in the given list.
|
public static java.util.List<java.lang.String> split(java.lang.String str,
char sep)
String.split(String). In particular, this method never returns an
empty list.
Examples:
split("a.b.c", '.') gives ["a", "b", "c"]
split("", '.') gives [""] (a list containing the empty string)
split(".", '.') gives ["", ""] (a list containing two empty strings)
split("..", '.') gives ["", "", ""] (a list containing three empty
strings)
split(".a...b.", '.') gives ["", "a", "", "", "b", ""] (a list containing
an empty string, the string "a", two empty strings, the string "b", and an empty string)
str - the String to splitsep - the separator to usepublic static void split(java.lang.String str,
char sep,
java.util.List<java.lang.String> list)
String.split(String). In
particular, this method always add at least one element to the list.
Examples:
split("a.b.c", '.') gives ["a", "b", "c"]
split("", '.') gives [""] (a list containing the empty string)
split(".", '.') gives ["", ""] (a list containing two empty strings)
split("..", '.') gives ["", "", ""] (a list containing three empty
strings)
split(".a...b.", '.') gives ["", "a", "", "", "b", ""] (a list containing
an empty string, the string "a", two empty strings, the string "b", and an empty string)
str - the String to splitsep - the separator to uselist - the list where to put the resultspublic static java.util.List<java.lang.String> splitLines(java.lang.String str)
str - the String to splitpublic static void splitLines(java.lang.String str,
java.util.List<java.lang.String> list)
str - the String to splitlist - the list where to put the result