Here you can find the source of stringToArray(String inputVal, String delimiter)
public static ArrayList<String> stringToArray(String inputVal, String delimiter)
//package com.java2s; import java.util.ArrayList; public class Main { public static ArrayList<String> stringToArray(String inputVal, String delimiter) { if (inputVal == null || inputVal.length() <= delimiter.length()) { return null; }/*from ww w . j a v a 2s . c o m*/ if (inputVal.indexOf(delimiter) == 0) { inputVal = inputVal.substring(delimiter.length()); } if (inputVal.indexOf(delimiter) == inputVal.length() - delimiter.length()) { inputVal = inputVal.substring(0, inputVal.length() - delimiter.length()); } String[] vals = inputVal.split(delimiter); ArrayList<String> returnList = new ArrayList<String>(); try { for (int i = 0; i < vals.length; i++) { returnList.add(vals[i].trim()); } } catch (Exception ex) { returnList = null; } return returnList; } }