DataOutputStream WriteByte() Example
Writes out a byte to the underlying output stream as a 1-byte value.
DataOutputStreamclass WriteByte() method example. This example shows you how to use WriteByte() method.This method Writes out a byte to the underlying output stream as a 1-byte value.
Here is the code:-
/**
* @Program that Writes out a byte to the underlying output stream.
* WriteByte.java
* Author:-RoseIndia Team
* Date:-09-jun-2008
*/
import java.io.*;
public class WriteByte {
public static void main(String[] args)throws IOException {
int a=65;
FileOutputStream fos=new FileOutputStream("g.txt");
DataOutputStream dos=new DataOutputStream(fos);
//Writes out a byte to the underlying output stream
dos.writeByte(a);
FileInputStream fis=new FileInputStream("g.txt");
DataInputStream dis=new DataInputStream(fis);
System.out.println("Byte to the underlying output stream is : "+dis.readByte());
}
} |
Output of the Program
| Byte to the underlying output stream is : 65 |
|