Here you can find the source of split(String src, char separator, boolean trim)
static public List<String> split(String src, char separator, boolean trim)
//package com.java2s; /*// ww w.j av a2 s. com * Copyright (C) 2014 Dell, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.ArrayList; import java.util.List; public class Main { static public List<String> split(String src, char separator, boolean trim) { List<String> result = new ArrayList<String>(); for (int i1 = 0; i1 < src.length();) { int i2 = src.indexOf(separator, i1); if (i2 < 0) i2 = src.length(); String item = src.substring(i1, i2); if (trim) item = item.trim(); result.add(item); i1 = i2 + 1; } return result; } static public String trim(String text, String whiteSpaces) { if (text == null || text.length() == 0) return text; int ind = 0; int len = text.length(); while (whiteSpaces.indexOf(text.charAt(ind)) != -1) ind += 1; while (whiteSpaces.indexOf(text.charAt(len - 1)) != -1) len -= 1; return text.substring(ind, len); } }