/* FileOutput.java CIS 160 David Klick 2004-09-08 Demonstrates writing data to a file. */ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; public class FileOutput { public static void main(String[] args) throws IOException { double num = 12.67; // File will be opened for output in same directory program // is running in. It will be created if it does not exist. // The previous contents will be erased if it does exist. PrintWriter out = new PrintWriter(new FileWriter("fout.txt")); // write data to file out.print("David"); out.print(" G."); out.println(" Klick"); out.println(num); out.println("That's all folks!"); out.close(); } }