Android examples for java.lang:String Split
Combine string array as string, split by token string
import java.io.UnsupportedEncodingException; import java.util.*; public class Main{ /**//w w w . j a v a 2 s .co m * Combine string array as string, split by token string * * @param strsInput Object array which includes elements to be combined * @param strToken split token * @return string combined with <code>strsInput</code>, splited by <code>strToken</code> */ public static String combineString(Object[] strsInput, String strToken) { if (strsInput == null) { return null; } StringBuffer sb = new StringBuffer(); int l = strsInput.length; for (int i = 0; i < l; i++) { sb.append(replaceNull(strsInput[i])); if (i < l - 1) { sb.append(strToken); } } return sb.toString(); } /** * Combine list as string with given token * * @param inputList list which includes elements requiring to be combined * @param token Token * @return String combined with <code>inputList</code> with <code>token</code> */ public static String combineString(List inputList, String token) { if (inputList == null) { return null; } StringBuffer sb = new StringBuffer(); for (Iterator iterator = inputList.iterator(); iterator.hasNext();) { sb.append(iterator.next().toString()); if (iterator.hasNext()) { sb.append(token); } } return sb.toString(); } }