Here you can find the source of split(String input, String... delimiters)
input
Parameter | Description |
---|---|
input | a parameter |
delimiters | a parameter |
public static List<String> split(String input, String... delimiters)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { /**//from w w w. ja v a2 s .c o m * If no delimiters are supplied, one-element list containing <code>input</code> * @param input * @param delimiters * @return */ public static List<String> split(String input, String... delimiters) { if (input == null) return null; String str = input; List<String> list = new ArrayList<String>(); if (delimiters == null || delimiters.length < 1) { list.add(input); return list; } String delim = delimiters[0]; for (int i = 1; i < delimiters.length; i++) { str = str.replaceAll(delimiters[i], delim); } String[] tmp = str.split(delim); for (int i = 0; i < tmp.length; i++) { list.add(tmp[i].trim()); } return list; } }