Java String Tokenize tokenizeNumbersFromString(String stream)

Here you can find the source of tokenizeNumbersFromString(String stream)

Description

tokenize Numbers From String

License

Open Source License

Declaration

public static ArrayList<String> tokenizeNumbersFromString(String stream) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

public class Main {
    public static ArrayList<String> tokenizeNumbersFromString(String stream) {
        ArrayList<String> output = new ArrayList<String>();
        boolean flag;
        for (int i = 0; i < stream.length(); i++) {
            String str = new String();
            flag = false;//from  ww w .j a  va 2  s .c o  m
            //System.out.println(isNumber(stream.charAt(i)) + " -> " + stream.charAt(i));
            if (isNumber(stream.charAt(i)))
                flag = true;
            while (i < stream.length() && isNumber(stream.charAt(i)))
                str += stream.charAt(i++);
            if (flag)
                output.add(str);
        }
        return output;
    }

    public static boolean isNumber(char digit) {
        boolean flag = false;
        if (digit == '0' || digit == '1' || digit == '2' || digit == '3' || digit == '4' || digit == '5'
                || digit == '6' || digit == '7' || digit == '8' || digit == '9')
            flag = true;
        return flag;
    }
}

Related

  1. tokenizeExpression(String s)
  2. tokenizeFilter(CharSequence filter)
  3. tokenizeLine(String input)
  4. tokenizeLine(String line)
  5. tokenizeName(String name)
  6. tokenizeOnWhitespace(String input)
  7. tokenizePath(String path)
  8. tokenizePathAsArray(String path)
  9. tokenizePattern(String pattern)