Write byte to file using BufferedOutputStream in Java
Description
The following code shows how to write byte to file using BufferedOutputStream.
Example
/*from ww w . ja va2s. c o m*/
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
public class Main {
public static void main(String[] args) throws Exception {
FileOutputStream fos = new FileOutputStream("C:/Demo.txt");
BufferedOutputStream bos = new BufferedOutputStream(fos);
byte b = 66;
// write a character represented by ascii 66 i.e. 'B'
bos.write(b);
bos.flush();
bos.close();
}
}