Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        String str = "This is a  test, this is another test.";
        String delimiters = "  ,"; // a space and a comma
        StringTokenizer st = new StringTokenizer(str, delimiters);

        System.out.println("Tokens  using a  StringTokenizer:");
        String token = null;
        while (st.hasMoreTokens()) {
            token = st.nextToken();
            System.out.println(token);
        }
    }
}