DataOutputStream Write() Example
Writes the specified byte to the underlying output stream.
DataOutputStreamclass Write() method example. This example shows you how to use Write() method.This method Writes the specified byte (the low eight bits of the argument b) to the underlying output stream.
Here is the code:-
/**
* @Program that Writes the specified byte to the underlying output stream.
* Write.java
* Author:-RoseIndia Team
* Date:-09-jun-2008
*/
import java.io.*;
public class Write {
public static void main(String[] args)throws IOException {
byte b=45;
FileOutputStream fos=new FileOutputStream("g.txt");
DataOutputStream dos=new DataOutputStream(fos);
//Writes the specified byte to the underlying output stream
dos.write(b);
FileInputStream fis=new FileInputStream("g.txt");
DataInputStream dis=new DataInputStream(fis);
System.out.println("Specified Byte is: "+dis.readByte());
}
} |
|