Create DataInputStream from FileInputStream : DataInputStream « File « Java Tutorial


public class MainClass {

  public static void main(String[] args) throws Exception {

    DataInputStream din = null;
    try {
      FileInputStream fin = new FileInputStream("myfile.dat");

      din = new DataInputStream(fin);
      while (true) {
        int theNumber = din.readInt();
    } catch (EOFException ex) {
    } catch (IOException ex) {

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.