Consider wrapping your FileOutputStream using a DataOutputStream and use the writeInt() and writeLong() methods. To speed up writes, it may also be beneficial to put an intermediary...