import java.io.*;
public class DataFileTest {
  public static void main(String[] args) 
                     throws Exception {
    int anInt = 555;
    double aDouble = 12345.6789;
    char aChar = 'C';
    String aString = "Hello World";
    
    DataOutputStream fOut = 
      new DataOutputStream(new FileOutputStream("somedata.dat"));
    fOut.writeInt(anInt);
    fOut.writeDouble(aDouble);
    fOut.writeChar(aChar);
    fOut.writeUTF(aString);
    fOut.flush();
    fOut.close();
    
    DataInputStream fIn =
      new DataInputStream(new FileInputStream("somedata.dat"));
    
    int anInt2 = fIn.readInt();
    double aDouble2 = fIn.readDouble();
    char aChar2 = fIn.readChar();
    String aString2 = fIn.readUTF();
    fIn.close();
    System.out.format(
        "int: %d%ndouble: %f%nchar: %s%nString: %s%n",
        anInt2, aDouble2, aChar2, aString2
    );
  }
}