From ac7e70883c18602e7fd4b525b9e6fb9ea9620a6b Mon Sep 17 00:00:00 2001 From: Keuin Date: Wed, 20 Jan 2021 19:50:42 +0800 Subject: refactor --- .../incremental/ObjectCollectionSerializer.java | 33 ---------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/main/java/com/keuin/kbackupfabric/util/backup/incremental/ObjectCollectionSerializer.java (limited to 'src/main/java/com/keuin/kbackupfabric/util/backup/incremental/ObjectCollectionSerializer.java') diff --git a/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/ObjectCollectionSerializer.java b/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/ObjectCollectionSerializer.java deleted file mode 100644 index 6f9b792..0000000 --- a/src/main/java/com/keuin/kbackupfabric/util/backup/incremental/ObjectCollectionSerializer.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.keuin.kbackupfabric.util.backup.incremental; - -import java.io.*; -import java.util.Objects; - -/** - * Serialize and deserialize ObjectCollection from/to the disk file. - */ -public class ObjectCollectionSerializer { - public static ObjectCollection fromFile(File file) throws IOException { - Objects.requireNonNull(file); - ObjectCollection collection; - try (FileInputStream fileInputStream = new FileInputStream(file)) { - try (ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) { - collection = (ObjectCollection) objectInputStream.readObject(); - } catch (ClassNotFoundException ignored) { - // this should not happen - return null; - } - } - return collection; - } - - public static void toFile(ObjectCollection collection, File file) throws IOException { - Objects.requireNonNull(collection); - Objects.requireNonNull(file); - try (FileOutputStream fileOutputStream = new FileOutputStream(file)) { - try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) { - objectOutputStream.writeObject(collection); - } - } - } -} -- cgit v1.2.3