// Set up the streams
File inFile = new File("C:\\Sample1.dat");
// FileInputStream reads bytes
FileInputStream ifs = new FileInputStream(inFile);
// DataOuputStream writes floats, ints, doubles
DataInputStream inDataStream = new DataInputStream(ifs);
// Try reading a few primitive values from the stream.
System.out.println("Integer " + inDataStream.readInt());
System.out.println("Integer " + inDataStream.readInt());
System.out.println("Characters " + inDataStream.readUTF());
System.out.println("Double " + inDataStream.readDouble());
System.out.println("Long " + inDataStream.readLong());
System.out.println("char " + inDataStream.readChar());
inDataStream.close();