Java - Write code to tokenize a string with Comma

Requirements

Write code to tokenize a string with Comma

Demo

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

public class Main {
    public static void main(String[] argv) {
        String str = "book2s,com";
        System.out.println(java.util.Arrays
                .toString(getFromCommaSeparated(str)));
    }/*  www .j  av  a2 s  .c  o  m*/

    public static String[] getFromCommaSeparated(String str) {
        StringTokenizer tokenizer = new StringTokenizer(str, ",");
        int count = tokenizer.countTokens();

        String[] array = new String[count];
        for (int i = 0; i < count; i++) {
            array[i] = tokenizer.nextToken();
        }

        return array;
    }
}