Split String to Array - Android java.lang

Android examples for java.lang:String Split

Description

Split String to Array

Demo Code

import java.io.UnsupportedEncodingException;
import java.util.*;

public class Main{

    /**/*from   ww  w  .  j  a  v a 2 s .  com*/
     * Split String to Array
     *
     * @param strInput  Input String with splitor
     * @param separator String Splitor
     * @return String Item in Array
     */
    public static String[] splitString2Array(String strInput,
            String separator) {
        String[] strArray = null;
        List lstResult = splitString(strInput, separator);
        if ((lstResult != null) && (lstResult.size() > 0)) {
            strArray = new String[lstResult.size()];
            int size = lstResult.size();
            for (int i = 0; i < size; i++) {
                strArray[i] = (String) lstResult.get(i);
            }
        }
        return strArray;
    }

}

Related Tutorials