/* Tokenize.java David Klick CIS 260 2011-06-21 Uses the String.split(RegEx) method to tokenize a String. */ import java.util.Scanner; public class Tokenize { public static void main(String[] args) { String input, delimiter; if (args.length != 2) { Scanner in = new Scanner(System.in); System.out.print("Enter line to be tokenized: "); input = in.nextLine(); System.out.print("Enter delimiter: "); delimiter = in.nextLine(); } else { input = args[0]; delimiter = args[1]; } String[] fields = input.split(delimiter); for (String s : fields) System.out.println(s); } }