Here you can find the source of split(final String string)
Por ejemplo
Parameter | Description |
---|---|
string | cadena a partir |
public static List<String> split(final String string)
//package com.java2s; /*-//from ww w. j ava2s . c o m * Copyright (c) * * 2012-2014, Facultad Polit?cnica, Universidad Nacional de Asunci?n. * 2012-2014, Facultad de Ciencias M?dicas, Universidad Nacional de Asunci?n. * 2012-2013, Centro Nacional de Computaci?n, Universidad Nacional de Asunci?n. * * 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 */ import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { private static final List<Character> MAYUSCULAS = Arrays.asList('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); /** * Dada una cadena escrita en camelCase retorna una lista con los elementos * que forman la cadena * <p> * <b>Por ejemplo</b> * <ol> * <li><b>HolaMundo</b>, retorna [Hola,Mundo]</li> * </ol> * * </p> * * @param string * cadena a partir * @return list de elementos */ public static List<String> split(final String string) { List<String> list = new ArrayList<String>(); int j = 0; for (int i = 1; i < string.length(); i++) { if (MAYUSCULAS.contains(string.charAt(i))) { list.add(string.substring(j, i)); j = i; } } list.add(string.substring(j, string.length())); return list; } }