/** * Write the json as bytes -then close the file * @param dataOutputStream an outout stream that will always be closed * @throws IOException on any failure */ private void writeJsonAsBytes(T instance, DataOutputStream dataOutputStream) throws IOException { try { byte[] b = toBytes(instance); dataOutputStream.write(b); } finally { dataOutputStream.close(); } }