Java String Tokenize parseString(String in, String token)

Here you can find the source of parseString(String in, String token)

Description

Utility method to test equality on two possibly null objects

License

Apache License

Parameter

Parameter Description
in non-null string
token token to break - if null use \n

Return

non-null

Declaration

public static String[] parseString(String in, String token) 

Method Source Code

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

import java.util.*;

public class Main {
    /**//from  w ww. j a v  a  2s . co  m
     * Utility method to test equality on two possibly null objects
     * @param in non-null string
     * @param token token to break - if null use \n
     * @return non-null
     */
    public static String[] parseString(String in, String token) {
        if (token == null)
            token = "\n";
        StringTokenizer st = new StringTokenizer(in, token);
        String[] ret = new String[st.countTokens()];
        int i = 0;
        while (st.hasMoreTokens())
            ret[i++] = st.nextToken();
        return (ret);
    }
}

Related

  1. isPOSTag(String token)
  2. isStringFunction(String token)
  3. isToken(String sentence, String searchWord)
  4. maxTokenLength(String s)
  5. parseNMTokens(String nmTokens)
  6. readTokens(String line)
  7. removeEmptyStrings(String[] tokens)
  8. removeMatchingRegex(String regex, String replacement, String[] tokens, boolean removeEmpty)
  9. removeStopWords(String[] tokens, Set stopWords)