StringTokenizer st = new StringTokenizer("Hello, World|of|Java", ", |", true); while (st.hasMoreElements()) System.out.println("Token: " + st.nextElement());