Java String to List stringToList(String str, String delim)

Here you can find the source of stringToList(String str, String delim)

Description

string To List

License

Open Source License

Declaration

public static List stringToList(String str, String delim) 

Method Source Code

//package com.java2s;
/**/*  www.  ja  v  a 2s  .c o  m*/
 * Copyright (c) 2003,2004 International Business Machines Corporation.
 * All Rights Reserved.
 *
 * This software is provided and licensed under the terms and conditions
 * of the Common Public License:
 * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html
 */

import java.util.*;

public class Main {
    public static List stringToList(String str, String delim) {
        return Arrays.asList(tokenize(str, delim));
    }

    public static String[] tokenize(String tokenStr, String delim) {
        StringTokenizer strTok = new StringTokenizer(tokenStr, delim);
        String[] tokens = new String[strTok.countTokens()];

        for (int i = 0; i < tokens.length; i++) {
            tokens[i] = strTok.nextToken();
        }

        return tokens;
    }
}

Related

  1. stringToList(String source)
  2. stringToList(String sText)
  3. stringToList(String str)
  4. stringToList(String str)
  5. stringToList(String str, char delimiter)
  6. stringToList(String string, String separator)
  7. stringToList(String text, String seperator)
  8. stringToList(String toList)
  9. stringToList(String toList, String delimiter)