<<< Formatted output: PrintWriter class | Index | Writing delimited text file >>> |
Code that appends a string and an object to a text file:
// open an output stream for appending to the text file PrintWriter out = new PrintWriter( new BufferedWriter( new FileWriter("log.txt", true))); // write a string and an object to the file out.print("This application was run on "); Date today = new Date(); out.println(today); // flush data to the file and close the output stream out.close();
<<< Formatted output: PrintWriter class | Index | Writing delimited text file >>> |