Here you can find the source of split(String line, String separator)
public static final String[] split(String line, String separator)
//package com.java2s; /**/*from www . j a va 2 s. co m*/ * Copyright 2010 ZTEsoft Inc. All Rights Reserved. * * This software is the proprietary information of ZTEsoft Inc. * Use is subject to license terms. * * $Tracker List * * $TaskId: $ $Date: 9:24:36 AM (May 9, 2008) $comments: create * $TaskId: $ $Date: 3:56:36 PM (SEP 13, 2010) $comments: upgrade jvm to jvm1.5 * * */ import java.util.*; public class Main { public static final String[] split(String line, String separator) { LinkedList<String> list = new LinkedList<String>(); if (line != null) { int start = 0; int end = 0; int separatorLen = separator.length(); while ((end = line.indexOf(separator, start)) >= 0) { list.add(line.substring(start, end)); start = end + separatorLen; } if (start < line.length()) { list.add(line.substring(start, line.length())); } } return (String[]) list.toArray(new String[list.size()]); } }