Java String Split splitTokens(final String targets)

Here you can find the source of splitTokens(final String targets)

Description

Simple function to split a string into tokens which are loaded into a list, note order IS important.

License

Apache License

Parameter

Parameter Description
targets String to split on one or more whitespace characters.

Return

List containing the tokens

Declaration

public static List<String> splitTokens(final String targets) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Arrays;
import java.util.List;

public class Main {
    /**/*from   www.jav  a2 s  .c om*/
     * Simple function to split a string into tokens which are loaded into a list, note order IS important.
     *
     * @param targets String to split on one or more whitespace characters.
     * @return List containing the tokens
     */
    public static List<String> splitTokens(final String targets) {

        if (targets.matches(".*\\s.*")) {
            return Arrays.asList(targets.split("\\s+"));
        } else {
            return Arrays.asList(targets);
        }

    }
}

Related

  1. splitTemplateName(String templateName)
  2. splitter(List list, final int L)
  3. splitTerms(String queryString)
  4. splitText(String text)
  5. splitToInteger(String str)
  6. splitTokens(String text)
  7. splitToList(final String listString, final String split)
  8. splitToList(String s)
  9. splitToList(String valueString)