<<< PrintWriter print( ) and println( ) | Index | Reader/Writer hierarchy -- character streams >>> |
Code that writes a Book object to a delimited text file
// open an output stream for overwriting a text file PrintWriter out = new PrintWriter( new BufferedWriter( new FileWriter(booksFile))); // write the Book object to the file out.print(book.getCode() + "\t"); out.print(book.getDescription() + "\t"); out.println(book.getPrice()); // flush data to the file and close the output stream out.close();
<<< PrintWriter print( ) and println( ) | Index | Reader/Writer hierarchy -- character streams >>> |