Java - Write code to tokenize a string to String array

Requirements

Write code to tokenize a string

Demo

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

public class Main {
    public static void main(String[] argv) {
        String value = "book2s.com";
        String delimiter = "o";
        System.out.println(java.util.Arrays
                .toString(convertValuesFromString(value, delimiter)));
    }//from  w ww .  java2 s.com

    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;
    }
}