Write boolean to a file using DataOutputStream - Java File Path IO

Java examples for File Path IO:DataOutputStream

Description

Write boolean to a file using DataOutputStream

Demo Code

 
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
 
public class Main {
 
  public static void main(String[] args) {
   // w  w  w .  j a  v a  2  s .  co  m
    String strFilePath = "C://Folder//WriteBoolean.txt";
   
    try
    {
      //create FileOutputStream object
      FileOutputStream fos = new FileOutputStream(strFilePath);
      DataOutputStream dos = new DataOutputStream(fos);
      boolean b = false;
      dos.writeBoolean(b);
      dos.close();
    }
    catch (IOException e)
    {
      System.out.println("IOException : " + e);
    }
  }
}

Result


Related Tutorials