Java - Write code to split a string using StringTokenizer

Requirements

Write code to split a string using StringTokenizer

Demo

//package com.book2s;

import java.util.StringTokenizer;

public class Main {
    public static void main(String[] argv) {
        String seperators = "book2s.com";
        String list = "o";
        System.out.println(java.util.Arrays
                .toString(split(seperators, list)));
    }// w  ww .  j a v  a2  s  .  c  om

    public static String[] split(String seperators, String list) {
        return split(seperators, list, false);
    }

    public static String[] split(String seperators, String list,
            boolean include) {
        StringTokenizer tokens = new StringTokenizer(list, seperators,
                include);
        String[] result = new String[tokens.countTokens()];
        int i = 0;
        while (tokens.hasMoreTokens()) {
            result[i++] = tokens.nextToken();
        }
        return result;
    }

    public static String toString(Object[] array) {
        int len = array.length;
        if (len == 0)
            return "";
        StringBuffer buf = new StringBuffer(len * 12);
        for (int i = 0; i < len - 1; i++) {
            buf.append(array[i]).append(", ");
        }
        return buf.append(array[len - 1]).toString();
    }
}