import java.io.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class OffsetUtil {
private OffsetUtil() {
}
public static boolean exOffsetFile(String path) {
File file = new File(path);
return file.exists();
}
public static void mapSerialize(Map<Integer, Date> hmap, String path) throws PluginException {
try (FileOutputStream fos = new FileOutputStream(path);
ObjectOutputStream oos = new ObjectOutputStream(fos)) {
oos.writeObject(hmap);
} catch (IOException e) {
throw new PluginException("map serialize error : " + e);
}
}
public static Map<Integer, Date> mapDeserialization(String path) throws PluginException {
HashMap<Integer, Date> map;
try (FileInputStream fis = new FileInputStream(path);
ObjectInputStream ois = new ObjectInputStream(fis)) {
map = (HashMap<Integer, Date>) ois.readObject();
return map;
} catch (IOException | ClassNotFoundException e) {
throw new PluginException("map deserialization error : " + e);
}
}
}