Mega Code Archive

 
Categories / Android / Date Type
 

Split and combine by token

import java.util.ArrayList; class StringUtils {   public static ArrayList<String> spliteByToken(String src, String token) {     String[] array = src.split(token);     ArrayList<String> ret = new ArrayList<String>();     for (String temp : array) {       if (temp != "") {         ret.add(temp);       }     }     return ret;   }   public static String combineByToken(ArrayList<String> list, String token) {     StringBuffer buf = new StringBuffer();     for (String temp : list) {       buf.append(token).append(temp);     }     if (buf.length() != 0) {       buf.deleteCharAt(0);// will refactory soon here     }     return buf.toString();   } }