import java.io.*; import java.util.StringTokenizer; public class FileGUI { /***************************************** * Ask the user for a file to open. * Read the first two lines and display * them to the user. * Write the lines to a file called * twolines.txt *****************************************/ static BufferedReader keyboard = new BufferedReader (new InputStreamReader (System.in)); public static void main (String[] args) throws FileNotFoundException, IOException { String message, file, line1, line2; PrintWriter outFile = new PrintWriter (new FileWriter ("output.dat")); StringTokenizer tokenizer; System.out.println ("Enter item and price separated " + "by spaces\n" + "(price 999 to quit): "); // parse the input and output to the user tokenizer = new StringTokenizer(keyboard.readLine()); String item = tokenizer.nextToken(); double price = Double.parseDouble(tokenizer.nextToken()); //while (price != 999) //{ outFile.println(item); outFile.println(price); // System.out.println ("Enter item and price separated by spaces\n" // + "(price 999 to quit): "); // tokenizer = new StringTokenizer(keyboard.readLine()); // item = tokenizer.nextToken(); // price = Double.parseDouble(tokenizer.nextToken()); // } outFile.close(); } // end of main method } // end of class FileGUI