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




















Home »
  Java Tutorial »
    I/O »




Binary File
Byte Array
CharSet
Checksum
Console
Create Copy Move Delete
Directory
Drive
Encode Decode
File Attribute
File Lock
File System
GZIP
Jar File
NIO Buffer
Path
Scanner
StreamTokenizer
Temporary File
Text File
Zip