private void writeCompressedObject(Path cacheFile, Object obj) throws IOException { assert cacheDir != null; Files.createDirectories(cacheDir); try (StagedWrite stage = StagedWrite.begin(cacheFile)) { try (OutputStream out = stage.openOutputStream(); OutputStream gzOut = new GZIPOutputStream(out); ObjectOutputStream objOut = new ObjectOutputStream(gzOut)) { objOut.writeObject(obj); } // now we commit, after closing the output files stage.commit(); } }
private void writeCompressedObject(Path cacheFile, Object obj) throws IOException { assert cacheDir != null; Files.createDirectories(cacheDir); try (StagedWrite stage = StagedWrite.begin(cacheFile)) { try (OutputStream out = stage.openOutputStream(); OutputStream gzOut = new GZIPOutputStream(out); ObjectOutputStream objOut = new ObjectOutputStream(gzOut)) { objOut.writeObject(obj); } // now we commit, after closing the output files stage.commit(); } }