new FileInputStream(String name) : FileInputStream « java.io « Java by API






new FileInputStream(String name)

 
/*
 * 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 FileInputStream(File file)
2.new FileInputStream(FileDescriptor fdObj)
3.FileInputStream: available()
4.FileInputStream: close()
5.FileInputStream: getChannel()
6.FileInputStream: getFD()
7.FileInputStream: read()