Here you can find the source of split(String s, String delim)
public static List<String> split(String s, String delim)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static List<String> split(String s, String delim) { List<String> list = new ArrayList<String>(); s = trim(s);//w w w. j a v a 2 s. c o m if (s == null) { return list; } String[] rs = s.split(delim); for (String str : rs) if (str.trim().length() > 0) { list.add(str); } return list; } public static String trim(String s) { if (s == null) { return ""; } return s.trim(); } public static String[] add(String[] array, String... strs) { Set<String> list = new HashSet<String>(Arrays.asList(array)); Collections.addAll(list, strs); return list.toArray(new String[list.size()]); } }