DataOutputStream WriteBoolean() Example

Writes a boolean to the underlying output stream as a 1-byte value.


DataOutputStreamclass WriteBoolean() method example. This example shows you how to use WriteBoolean() method.This method Writes a boolean to the underlying output stream as a 1-byte value.

Here is the code:-
/**
 * @Program that Writes a boolean to the underlying output stream.
 * WriteBoolean.java 
 * Author:-RoseIndia Team
 * Date:-09-jun-2008
 */
import java.io.*;
public class WriteBoolean {
public static void main(String[] argsthrows IOException{
boolean b=true;
FileOutputStream fos=new FileOutputStream("g.txt");    
DataOutputStream dos=new DataOutputStream(fos);
//Writes a boolean to the underlying output stream
dos.writeBoolean(b);
FileInputStream fis=new FileInputStream("g.txt");    
DataInputStream dis=new DataInputStream(fis);
System.out.println("Boolean to the underlying output stream is : "+dis.readBoolean());  
}
}

Output of the Program
 Boolean to the underlying output stream is : true

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US