Write byte to file using BufferedOutputStream : BufferedOutputStream « File Input Output « Java






Write byte to file using BufferedOutputStream

  

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();
  }
}

   
    
  








Related examples in the same category

1.Write to file using BufferedOutputStream
2.Write byte array to file using BufferedOutputStream
3.Create BufferedOutputStream from FileOutputStream
4.Fast BufferedOutputStream