Here you can find the source of split(String src, char delim)
Parameter | Description |
---|---|
src | the string to split |
delim | the delimiter character |
String[]
value
public static String[] split(String src, char delim)
//package com.java2s; import java.util.ArrayList; public class Main { /**//ww w . j a va2 s .c om * Faster implementation of string splitting on a single character delimiter. * @param src the string to split * @param delim the delimiter character * @return a <code>String[]</code> value */ public static String[] split(String src, char delim) { return split(src, delim, 0); } /** * Faster implementation of string splitting on a single character delimiter. * @param src the string to split * @param delim the delimiter character * @param limit return at most limit - 1 entries, 0 or below for as many as necessary. * @return a <code>String[]</code> value */ public static String[] split(String src, char delim, int limit) { final ArrayList<String> output = new ArrayList<>(); int index; int lindex = 0; final boolean limited = limit > 0; while ((index = src.indexOf(delim, lindex)) != -1 && (!limited || output.size() < limit - 1)) { output.add(src.substring(lindex, index)); lindex = index + 1; } output.add(src.substring(lindex)); return output.toArray(new String[output.size()]); } }