Java - Write code to split a string by a delimiter using StringTokenizer


Write code to split a string


//package com.book2s;

import java.util.ArrayList;

import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;

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

    public static String[] split(String str, String delimiters) {
        final StringTokenizer st = new StringTokenizer(str, delimiters);
        final List<String> tokens = new ArrayList<String>();
        while (st.hasMoreTokens()) {
            final String token = st.nextToken();
        return tokens.toArray(new String[tokens.size()]);