Here you can find the source of split(String value, char delimiter)
Parameter | Description |
---|---|
value | string to be split |
delimiter | delimiter |
public static String[] split(String value, char delimiter)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { /**//from w w w .ja v a2 s . c o m * Splits a string in parts, given a specified delimiter. * * @param value string to be split * @param delimiter delimiter * @return */ public static String[] split(String value, char delimiter) { if (value == null) return null; ArrayList<String> result = new ArrayList<>(); int start = 0; for (int i = 0; i < value.length(); i++) { if (value.charAt(i) == delimiter) { result.add(value.substring(start, i)); start = i + 1; } } result.add(value.substring(start)); return result.toArray(new String[result.size()]); } }