new DataInputStream(FileInputStream fileInputStream) : DataInputStream « java.io « Java by API






new DataInputStream(FileInputStream fileInputStream)

  
/*
 * Output:
 */

import java.io.DataInputStream;
import java.io.FileInputStream;

public class MainClass {

  public static void main(String args[]) {
    try {

      FileInputStream fis = new FileInputStream("fileName.dat");

      // Create a data input stream
      DataInputStream dis = new DataInputStream(fis);

      // Read and display data
      System.out.println(dis.readBoolean());
      System.out.println(dis.readByte());
      System.out.println(dis.readChar());
      System.out.println(dis.readDouble());
      System.out.println(dis.readFloat());
      System.out.println(dis.readInt());
      System.out.println(dis.readLong());
      System.out.println(dis.readShort());

      // Close file input stream
      fis.close();
    } catch (Exception e) {
      System.out.println("Exception: " + e);
    }
  }
}

           
         
    
  








Related examples in the same category

1.new DataInputStream(new BufferedInputStream(new FileInputStream("temp.tmp")))
2.DataInputStream: readBoolean()
3.DataInputStream: readByte()
4.DataInputStream: readChar()
5.DataInputStream: readDouble()
6.DataInputStream: readFloat()
7.DataInputStream: readInt()
8.DataInputStream: readLong()
9.DataInputStream: readShort()
10.DataInputStream: readUnsignedShort()
11.DataInputStream: readUTF()