Java BufferedOutputStream write byte to a file

Description

Java BufferedOutputStream write byte to a file

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;

public class Main {
  public static void main(String[] args) throws Exception {
    FileOutputStream fos = new FileOutputStream("Main.java");
    BufferedOutputStream bos = new BufferedOutputStream(fos);
    byte b = 66;/* ww  w  . jav  a  2s.  c  om*/
    // write a character represented by ascii 66 i.e. 'B'
    bos.write(b);
    bos.flush();
    bos.close();
  }
}



PreviousNext

Related