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