Search in sources :

Example 31 with ObjectInputStream

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;
}
Also used : IOException(java.io.IOException) LocalDate(java.time.LocalDate) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) SMException(SMExceptions.SMException) ObjectInputStream(java.io.ObjectInputStream)

Example 32 with ObjectInputStream

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;
}
Also used : IOException(java.io.IOException) LocalDate(java.time.LocalDate) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) SMException(SMExceptions.SMException) ObjectInputStream(java.io.ObjectInputStream)

Example 33 with ObjectInputStream

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();
}
Also used : File(java.io.File) FileInputStream(java.io.FileInputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 34 with ObjectInputStream

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;
}
Also used : File(java.io.File) FileInputStream(java.io.FileInputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 35 with ObjectInputStream

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;
    }
}
Also used : Path(java.nio.file.Path) ObjectInputStream(java.io.ObjectInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) LocalDate(java.time.LocalDate) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

ObjectInputStream (java.io.ObjectInputStream)2159 ByteArrayInputStream (java.io.ByteArrayInputStream)1406 ObjectOutputStream (java.io.ObjectOutputStream)970 ByteArrayOutputStream (java.io.ByteArrayOutputStream)807 IOException (java.io.IOException)752 Test (org.junit.Test)458 FileInputStream (java.io.FileInputStream)339 File (java.io.File)197 InputStream (java.io.InputStream)157 ArrayList (java.util.ArrayList)90 BufferedInputStream (java.io.BufferedInputStream)84 Serializable (java.io.Serializable)66 FileNotFoundException (java.io.FileNotFoundException)64 FileOutputStream (java.io.FileOutputStream)63 HashMap (java.util.HashMap)63 Socket (java.net.Socket)49 Map (java.util.Map)48 ObjectInput (java.io.ObjectInput)45 GZIPInputStream (java.util.zip.GZIPInputStream)44 List (java.util.List)37