/** * Serializes object to output stream. * @param object object to be serialized * @param outputStream serialization stream * @throws IOException if an error occurs */ private static void serialize(Serializable object, OutputStream outputStream) throws IOException { final ObjectOutputStream oos = new ObjectOutputStream(outputStream); try { oos.writeObject(object); } finally { flushAndCloseOutStream(oos); } }
/** * Cleans up the object and updates the cache file. * @throws IOException when there is a problems with file save */ public void persist() throws IOException { final Path path = Paths.get(fileName); final Path directory = path.getParent(); if (directory != null) { Files.createDirectories(directory); } OutputStream out = null; try { out = Files.newOutputStream(path); details.store(out, null); } finally { flushAndCloseOutStream(out); } }
/** * Serializes object to output stream. * @param object object to be serialized * @param outputStream serialization stream * @throws IOException if an error occurs */ private static void serialize(Serializable object, OutputStream outputStream) throws IOException { final ObjectOutputStream oos = new ObjectOutputStream(outputStream); try { oos.writeObject(object); } finally { flushAndCloseOutStream(oos); } }
/** * Cleans up the object and updates the cache file. * @throws IOException when there is a problems with file save */ public void persist() throws IOException { final Path path = Paths.get(fileName); final Path directory = path.getParent(); if (directory != null) { Files.createDirectories(directory); } OutputStream out = null; try { out = Files.newOutputStream(path); details.store(out, null); } finally { flushAndCloseOutStream(out); } }