Android String Tokenize tokens(String stringrep, String separatorChars, boolean trim, boolean ignoreBlanks)

Here you can find the source of tokens(String stringrep, String separatorChars, boolean trim, boolean ignoreBlanks)

Description

tokens

Declaration

public static List<String> tokens(String stringrep,
            String separatorChars, boolean trim, boolean ignoreBlanks) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;

import java.util.List;
import java.util.StringTokenizer;

import android.text.TextUtils;

public class Main {
    public static List<String> tokens(String stringrep,
            String separatorChars, boolean trim, boolean ignoreBlanks) {
        List<String> l = new ArrayList<String>();
        StringTokenizer stz = new StringTokenizer(stringrep, separatorChars);
        String s = null;/*from w  ww.j  a v  a  2s . c o  m*/
        while (stz.hasMoreTokens()) {
            s = stz.nextToken();
            if (trim) {
                s = s.trim();
            }
            if (!(ignoreBlanks && TextUtils.isEmpty(s)))
                l.add(s);
        }
        return l;
    }
}

Related

  1. tokenize(String input, String token)