Here you can find the source of stringToList(String str, char delimiter)
Parameter | Description |
---|---|
str | String to creates List from |
delimiter | delimiter to split string |
public static List stringToList(String str, char delimiter)
//package com.java2s; //License from project: LGPL import java.util.ArrayList; import java.util.List; public class Main { /**//from w ww . ja v a 2s .c om * creates a List from a String "List" * @param str String to creates List from * @param delimiter delimiter to split string * @return List */ public static List stringToList(String str, char delimiter) { ArrayList list = new ArrayList(); int len = str.length(); if (len == 0) return list; StringBuffer el = new StringBuffer(); for (int i = 0; i < len; i++) { char c = str.charAt(i); if (c == delimiter) { list.add(el.toString()); if (el.length() > 0) el = new StringBuffer(); } else { el.append(c); } } list.add(el.toString()); return list; } }