Here you can find the source of split(char sep, String input)
public static List<String> split(char sep, String input)
//package com.java2s; /******************************************************************************* * Copyright (c) 2009, 2014 Xored Software Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://w ww . j ava2 s. c o m * Xored Software Inc - initial API and implementation and/or initial documentation *******************************************************************************/ import java.util.ArrayList; import java.util.List; public class Main { public static List<String> split(char sep, String input) { return split(Character.toString(sep), input); } public static List<String> split(String sep, String input) { List<String> result = new ArrayList<String>(); int start = 0; int nextSep; int sepLength = sep.length(); while ((nextSep = input.indexOf(sep, start)) != -1) { result.add(input.substring(start, nextSep)); start = nextSep + sepLength; } result.add(input.substring(start)); return result; } }