import java.io.*; import java.util.*; public class milesReader{ public static void main(String args[]) { try { // This is one way to read from a file. The list of all 5-letter words // is in a file called words.dat BufferedReader in = new BufferedReader(new FileReader("miles.dat")); String word; // Skip four lines word = in.readLine(); word = in.readLine(); word = in.readLine(); word = in.readLine(); // reads the remaining lines // while( (word = in.readLine()) != null ) // { // process a line containing a city name // This is to process a city name line word = in.readLine(); // Here is the example that uses comma, left square bracket, and right square bracket // as delimiters, all at once. StringTokenizer st = new StringTokenizer(word, ",[]"); while(st.hasMoreTokens()) System.out.println(st.nextToken()); // Now you should process the mileage data } catch (IOException e) {} } }