// File: FileIO2.java // // Author: Rahul Simha // Created: Aug 18, 1998. // // Illustrates writing to a file. import java.io.*; public class FileIO2 { public static void main (String[] argv) { try { // Need to associate a file with a PrintWriter. FileWriter fr = new FileWriter ("testdata2"); PrintWriter pw = new PrintWriter (fr); // Now we're ready for writing. pw.println ("Hello"); pw.println ("Hello again"); // Done. pw.close(); } catch (IOException e) { System.out.println (e); } } }