int i = 42;
double d = Math.PI;
String FILENAME = "binary.dat";
DataOutputStream os = new DataOutputStream(
new FileOutputStream(FILENAME));
os.writeInt(i);
os.writeDouble(d);
os.close();
System.out.println("Wrote " + i + ", " + d + " to file " + FILENAME);