// BufferedOutputStream example
// Demonstrates buffered writing for improved performance
// Buffer temporarily stores data before writing to file
// flush() forces buffer contents to be written
import java.io.*;
public class BufferedOutputExample {
public static void main(String[] args) {
try {
FileOutputStream fos = new FileOutputStream("output.txt");
BufferedOutputStream bos = new BufferedOutputStream(fos); // add output buffer!!!
bos.write("Hello World".getBytes());
bos.flush(); // force write buffer contents
bos.close();
} catch(IOException e) {
e.printStackTrace();
}
}
}
