Byte streams process data byte by byte (8 bits). For example FileInputStream is used to read from source and FileOutputStream to write to the destination.


public class Byte_Stream {

public static void main(String[] args) {

try {


FileOutputStream output=new FileOutputStream("C:\\Users\\Raazu\\Desktop\\bca.txt");

int content=1011011; output.write((byte) content);


("Byte Stream written successfully !"); output.close();


FileInputStream input=new FileInputStream("C:\\Users\\Raazu\\Desktop\\bca.txt");

int; System.out.println((char) data); input.close();


}catch(Exception e) { System.out.println(e);




When to use Character Stream over Byte Stream?

  • In Java, characters are stored using Unicode conventions. Character stream is useful when we want to process text files. These text files can be processed character by A character size is typically 16 bits.

When to use Byte Stream over Character Stream?

  • Byte oriented reads byte by byte. A byte stream is suitable for processing raw data like binary