Java Create a BufferedOutputStream

Java Create a BufferedOutputStream

To create a BufferedOutputStream in Java, you can use the following code:

BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("output.txt"));
Sourc‮:e‬www.lautturi.com

This code creates a new BufferedOutputStream called out that writes to the file "output.txt". The BufferedOutputStream wraps a FileOutputStream, which is used to write to the file.

You can then use the write method of the BufferedOutputStream to write data to the file, like this:

out.write(65); // writes the byte with the value 65 (ASCII value of 'A') to the file

It is important to remember to close the BufferedOutputStream when you are finished writing to the file, to release any resources that it is using. You can do this using the close method, like this:

out.close();
Created Time:2017-11-03 00:14:38  Author:lautturi