Java String Tokenize tokenizeOnWhitespace(String input)

Here you can find the source of tokenizeOnWhitespace(String input)

Description

tokenize On Whitespace

License

Open Source License

Declaration

public static String[] tokenizeOnWhitespace(String input) 

Method Source Code

//package com.java2s;
// This package is part of the Spiralcraft project and is licensed under

import java.util.ArrayList;

public class Main {
    public static String[] tokenizeOnWhitespace(String input) {
        ArrayList<String> out = new ArrayList<String>();

        int mark = -1;
        for (int i = 0; i < input.length(); i++) {
            if (Character.isWhitespace(input.charAt(i))) {
                if (i - mark > 1) {
                    out.add(input.substring(mark + 1, i));
                }//from  w  w  w . j av  a 2 s  .  c  o  m
                mark = i;
            }
        }
        if (input.length() - mark > 1) {
            out.add(input.substring(mark + 1, input.length()));
        }
        return out.toArray(new String[out.size()]);
    }
}

Related

  1. tokenizeFilter(CharSequence filter)
  2. tokenizeLine(String input)
  3. tokenizeLine(String line)
  4. tokenizeName(String name)
  5. tokenizeNumbersFromString(String stream)
  6. tokenizePath(String path)
  7. tokenizePathAsArray(String path)
  8. tokenizePattern(String pattern)
  9. tokenizeQuotedStrings(final String aInput, final String aDelimiters)