Java Utililty Methods String Split by Space

List of utility methods to do String Split by Space

Description

The list of methods to do String Split by Space are organized into topic(s).

Method

ListsplitStringOnWhitespace(String text)
Split the given String on whitespace characters.
List elements = new ArrayList();
StringBuffer buffer = new StringBuffer();
char[] chars = text.toCharArray();
for (int i = 0; i < chars.length; i++) {
    if (Character.isWhitespace(chars[i])) {
        if (buffer.length() > 0) {
            elements.add(buffer.toString());
            buffer = new StringBuffer();
...
String[]splitWithoutWhitespace(String source, String separator)
split Without Whitespace
List<String> result = new ArrayList<String>();
String[] items = source.split(separator);
for (String s : items) {
    if (!"".equals(s.trim())) {
        result.add(s.trim());
return result.toArray(new String[result.size()]);
...
CollectionwhitespaceSplit(final String input)
whitespace Split
if (input == null) {
    return Collections.emptyList();
final String[] splitValues = input.trim().split("\\s+");
return Arrays.asList(splitValues);