Read boolean from file using DataInputStream in Java

Description

The following code shows how to read boolean from file using DataInputStream.

Example


// www .j a v a  2  s  .  c om
import java.io.DataInputStream;
import java.io.FileInputStream;

public class Main {

  public static void main(String[] args) throws Exception {
    FileInputStream fin = new FileInputStream("C:/n.txt");
    DataInputStream din = new DataInputStream(fin);
    boolean b = din.readBoolean();
    System.out.println("boolean : " + b);
    din.close();
  }
}




















Home »
  Java Tutorial »
    I/O »




Binary File
Byte Array
CharSet
Checksum
Console
Create Copy Move Delete
Directory
Drive
Encode Decode
File Attribute
File Lock
File System
GZIP
Jar File
NIO Buffer
Path
Scanner
StreamTokenizer
Temporary File
Text File
Zip