code: public static void serialize(File file, SerializableObject object) throws IOException {
  		AtomicFile atomicFile = new AtomicFile(file);
  		FileOutputStream stream = null;
  		try {
  			stream = atomicFile.startWrite();
  			DataOutputStream out = new DataOutputStream(stream);
  			object.writeExternal(out);
  			atomicFile.finishWrite(stream); // serialization was successful
  		} catch (Exception e) {
  			atomicFile.failWrite(stream); // serialization failed
  			throw new IOException(e); // throw exception up the chain
  		}
  	}
docs: Writes an object ot a file