Here you can find the source of split(final String str, final char delim)
Parameter | Description |
---|---|
str | a parameter |
delim | a parameter |
public static String[] split(final String str, final char delim)
//package com.java2s; /******************************************************************************* * Manchester Centre for Integrative Systems Biology * University of Manchester/* w w w . ja v a 2 s. co m*/ * Manchester M1 7ND * United Kingdom * * Copyright (C) 2008 University of Manchester * * This program is released under the Academic Free License ("AFL") v3.0. * (http://www.opensource.org/licenses/academic.php) *******************************************************************************/ import java.util.*; public class Main { /** * * @param str * @param delim * @return String[] */ public static String[] split(final String str, final char delim) { final List<String> tokens = new ArrayList<>(); final char[] charArray = str.toCharArray(); final StringBuffer token = new StringBuffer(); for (int i = 0; i < charArray.length; i++) { if (charArray[i] == delim) { tokens.add(token.toString()); token.setLength(0); } else { token.append(charArray[i]); } } if (token.length() > 0) { tokens.add(token.toString()); } return tokens.toArray(new String[tokens.size()]); } }