Here you can find the source of split(String str, String delimiter)
public static String[] split(String str, String delimiter)
//package com.java2s; /*(C) 2007-2012 Alibaba Group Holding Limited. *This program is free software; you can redistribute it and/or modify *it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * Authors: // w w w.ja va2 s.c o m * junyu <junyu@taobao.com> , shenxun <shenxun@taobao.com>, * linxuan <linxuan@taobao.com> ,qihao <qihao@taobao.com> */ import java.util.ArrayList; public class Main { public static String[] split(String str, String delimiter) { String[] strs = str.split(delimiter); ArrayList<String> list = new ArrayList<String>(strs.length); for (String s : strs) { if (s != null && (s = s.trim()).length() > 0) { list.add(s); } } return list.toArray(new String[0]); } public static String trim(String str) { if (str != null) { return str.trim(); } return null; } }