Java String Tokenize tokenize(String array, String delimiter)

Here you can find the source of tokenize(String array, String delimiter)

Description

Split string into tokens using delimiter

License

Open Source License

Parameter

Parameter Description
array Monotone string
delimiter String separator

Return

Array of tokens

Declaration

public static List<String> tokenize(String array, String delimiter) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    /**//from   w  w  w  . j  a v  a2 s  .  com
     * Split string into tokens using delimiter
     * @param array Monotone string
     * @param delimiter String separator
     * @return Array of tokens
     */
    public static List<String> tokenize(String array, String delimiter) {
        final List<String> tokens = Arrays.asList(array.split("\\s*" + delimiter + "\\s*"));
        ArrayList<String> result = new ArrayList<>();
        for (String token : tokens) {
            if (token != null && !token.trim().isEmpty()) {
                result.add(token.trim());
            }
        }
        return result;
    }
}

Related

  1. stringTokenizer(String in)
  2. substringsBetween(final String str, final String open, final String close, boolean tokenReservedFlag)
  3. tokenArray(StringTokenizer st)
  4. tokenize(final String aInput, final String aDelimiters)
  5. tokenize(final String s)
  6. tokenize(String formula)
  7. tokenize(String in)
  8. tokenize(String input)
  9. tokenize(String input)