/* * Moonlight|3D Copyright (C) 2007 The Moonlight|3D team * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Created on Feb 14, 2007 */ package ml.core.helper; /** * * Simple and fast String helper functions. These are simplified replacements * of functions found in the Java class library that achieve a much higher * performance than their standard counterparts because they have significantly * less features. They are designed as special case optimisations and not as * general replacements. * * @author gregor */ public class StringTools { public static String[] split(String string, char token) { String[] result; // token can't match if string is empty, so pack string in array and return it if(string.length()==0) { result=new String[1]; result[0]=string; return result; } int matchPositions[]=new int[string.length()]; int numMatches=0; for(int i=0;i