First page Back Continue Last page Summary Graphic
Testbed for the Scanner
import java.io.*;
public class ScannerTest implements Tokens {
static public void main(String[] args) {
try {
// create and initialize scanner
Scanner s = new Scanner(new FileInputStream(args[0]));
s.nextToken();
// print out all tokens
while (s.token != EOF) {
System.out.println(s.representation());
s.nextToken();
}
} catch (IOException e) {
System.out.println(e.toString());
}
}
}