Java - Write code to tokenize a string to String array


Write code to tokenize a string


//package com.book2s;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] argv) {
        String value = "";
        String delimiter = "o";
                .toString(convertValuesFromString(value, delimiter)));
    }//from w w w  .ja  v a  2 s .c  o m

    static public String[] convertValuesFromString(String value,
            String delimiter) {
        StringTokenizer tokenizer = new StringTokenizer(value, delimiter);
        int tokenCount = tokenizer.countTokens();
        String[] elements = new String[tokenCount];

        for (int i = 0; i < tokenCount; i++) {
            elements[i] = tokenizer.nextToken();

        return elements;