Java String Tokenize getTokens(String msg, String delim)

Here you can find the source of getTokens(String msg, String delim)

Description

get Tokens

License

Open Source License

Declaration

public static String[] getTokens(String msg, String delim) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2007, 2010 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from  w  w  w . jav  a2s  . c  o  m*/
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

import java.util.*;

public class Main {
    public static String[] getTokens(String msg, String delim) {
        return getTokens(msg, delim, false);
    }

    public static String[] getTokens(String msg, String delim, boolean returnDelims) {
        StringTokenizer targetST = new StringTokenizer(msg, delim, returnDelims);
        String[] tokens = new String[targetST.countTokens()];
        ArrayList list = new ArrayList(targetST.countTokens());
        while (targetST.hasMoreTokens()) {
            list.add(targetST.nextToken());
        }
        list.toArray(tokens);
        return tokens;
    }
}

Related

  1. getParamString(StringTokenizer s)
  2. getSQLTokens(String query)
  3. getStringTokens(String str)
  4. getTokenArray(String sequence, String[] chain, boolean paired, boolean includeDelim)
  5. getTokens(final String s)
  6. getTokens(String str, String delim)
  7. getTokens(String str, String delimiter)
  8. getTokens(String string)
  9. getTokens(String string)