<<< DataOutputStream methods | Index | InputStream hierarchy, raw byte streams >>> |
Code that writes data to a binary file
DataOutputStream out = new DataOutputStream( new BufferedOutputStream( new FileOutputStream("books.bin"))); // write a Book object to the file out.writeUTF(book.getCode()); out.writeUTF(book.getDescription()); out.writeDouble(book.getPrice()); // flush data to the file and close the output stream out.close();
<<< DataOutputStream methods | Index | InputStream hierarchy, raw byte streams >>> |