use of java.io.ObjectInputStream in project SmartCity-Market by TechnionYP5777.
the class PictureManager method checkIfMostUpdate.
public static boolean checkIfMostUpdate(LocalDate d) throws IOException {
ObjectInputStream objectinputstream = null;
LocalDate updatedDate = null;
try {
FileInputStream streamIn = new FileInputStream(GuiCommonDefs.productsPicturesPathLastUpdate);
objectinputstream = new ObjectInputStream(streamIn);
updatedDate = (LocalDate) objectinputstream.readObject();
} catch (Exception e) {
throw new IOException();
} finally {
if (objectinputstream != null)
objectinputstream.close();
}
return updatedDate != null && d.compareTo(updatedDate) >= 0;
}
use of java.io.ObjectInputStream in project SmartCity-Market by TechnionYP5777.
the class PictureManager method getCurrentDate.
public static LocalDate getCurrentDate() throws IOException {
ObjectInputStream objectinputstream = null;
LocalDate updatedDate = null;
try {
FileInputStream streamIn = new FileInputStream(GuiCommonDefs.productsPicturesPathLastUpdate);
objectinputstream = new ObjectInputStream(streamIn);
updatedDate = (LocalDate) objectinputstream.readObject();
} catch (Exception e) {
throw new IOException();
} finally {
if (objectinputstream != null)
objectinputstream.close();
}
return updatedDate;
}
use of java.io.ObjectInputStream in project TotalFreedomMod by TotalFreedom.
the class ProtectArea method onStart.
@Override
protected void onStart() {
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean()) {
return;
}
File input = new File(plugin.getDataFolder(), DATA_FILENAME);
try {
if (input.exists()) {
FileInputStream fis = new FileInputStream(input);
ObjectInputStream ois = new ObjectInputStream(fis);
areas.clear();
areas.putAll((HashMap<String, SerializableProtectedRegion>) ois.readObject());
ois.close();
fis.close();
}
} catch (Exception ex) {
input.delete();
FLog.severe(ex);
}
cleanProtectedAreas();
}
use of java.io.ObjectInputStream in project TotalFreedomMod by TotalFreedom.
the class SavedFlags method getSavedFlags.
@SuppressWarnings("unchecked")
public Map<String, Boolean> getSavedFlags() {
Map<String, Boolean> flags = null;
File input = new File(TotalFreedomMod.plugin().getDataFolder(), SAVED_FLAGS_FILENAME);
if (input.exists()) {
try {
try (FileInputStream fis = new FileInputStream(input);
ObjectInputStream ois = new ObjectInputStream(fis)) {
flags = (HashMap<String, Boolean>) ois.readObject();
}
} catch (Exception ex) {
FLog.severe(ex);
}
}
return flags;
}
use of java.io.ObjectInputStream in project Synthese_2BIN by TheYoungSensei.
the class ListeTarifs method deserialize.
@SuppressWarnings("unchecked")
public static boolean deserialize() {
Assembly.getInstance().getListeTarifs();
Path p = FileSystems.getDefault().getPath(ListeTarifs.NOM_FICHIER);
try (InputStream in = Files.newInputStream(p);
ObjectInputStream o = new ObjectInputStream(in)) {
Assembly.getInstance().getListeTarifs().tarifs = (TreeMap<LocalDate, Tarif>) o.readObject();
return true;
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
return false;
}
}
Aggregations