Here you can find the source of stringToList(final String stringToTransform)
public static List<String> stringToList(final String stringToTransform)
//package com.java2s; /*// w w w . j a v a 2 s . c o m * * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at license/ESCIDOC.LICENSE * or http://www.escidoc.org/license. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at license/ESCIDOC.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ import java.util.ArrayList; import java.util.List; public class Main { public static List<String> stringToList(final String stringToTransform) { List<String> list = new ArrayList<String>(); String transformingString = stringToTransform; int index; if (transformingString.indexOf(",") != -1) { while ((index = transformingString.indexOf(",")) != -1) { list.add(transformingString.substring(0, index).trim()); transformingString = transformingString.substring(index + 1); } list.add(transformingString.trim()); } else if (transformingString.length() != 0) { list.add(transformingString.trim()); } return list; } }