Read float from file using DataInputStream : DataInputStream « File « Java Tutorial






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

public class Main {

  public static void main(String[] args) throws Exception {
    FileInputStream fin = new FileInputStream("C:/Float.txt");
    DataInputStream din = new DataInputStream(fin);

    float f = din.readFloat();
    System.out.println("float : " + f);
    din.close();
  }
}








11.17.DataInputStream
11.17.1.Create DataInputStream from FileInputStream
11.17.2.Create DataInputStream from BufferedInputStream and FileInputStream
11.17.3.Create DataInputStream from ByteArrayInputStream
11.17.4.Read int from DataInputStream
11.17.5.Read double from DataInputStream
11.17.6.Read double and UTF from DataInputStream with BufferedInputStream backended
11.17.7.Read boolean from file using DataInputStream
11.17.8.Read byte array from file using DataInputStream
11.17.9.Read byte from file using DataInputStream
11.17.10.Read char from file using DataInputStream
11.17.11.Read float from file using DataInputStream
11.17.12.Read long from file using DataInputStream
11.17.13.Read short from file using DataInputStream
11.17.14.Read unsigned byte from file using DataInputStream
11.17.15.Check the class version
11.17.16.Create a compressed data file by using a DeflaterOutputStream and then read that data through an InflaterInputStream.
11.17.17.Use DataInputStream to create double
11.17.18.Testing for end of file while reading a byte at a time.
11.17.19.This class is an part implementation of DataInput. It wraps a Reader object.