Example usage for java.io ObjectInputStream close

List of usage examples for java.io ObjectInputStream close

Introduction

In this page you can find the example usage for java.io ObjectInputStream close.

Prototype

public void close() throws IOException 

Source Link

Document

Closes the input stream.

Usage

From source file:calendarioSeries.vistas.MainViewController.java

public MainViewController() {
    mesActual = new Mes();
    Calendar cal = Calendar.getInstance();
    this.hoy = cal.get(Calendar.DAY_OF_MONTH);
    this.esteMes = mesActual.getNumMes();
    this.esteAno = mesActual.getNumAno();

    File file = new File("data.db");
    FileInputStream fis;/*from   ww w . java 2  s. co m*/
    ObjectInputStream ois;
    try {
        fis = new FileInputStream(file);
        ois = new ObjectInputStream(fis);
        this.series = (ArrayList<Serie>) ois.readObject();
        ois.close();
    } catch (IOException ex) {
        ex.printStackTrace();
        this.series = new ArrayList<>();
        try {
            File datos = new File("seriesUsuario.json");
            Scanner in = new Scanner(datos);
            String toJson = "";
            while (in.hasNext()) {
                toJson += in.nextLine();
            }
            JSONObject sesion = new JSONObject(toJson);
            Set<String> ids = sesion.keySet();
            for (String id : ids) {
                Serie aux = new Serie(id);
                if (series.contains(aux)) {
                    JSONArray lastVisto = sesion.getJSONArray(id).getJSONArray(1);
                    aux.setVistosHasta(lastVisto.getInt(0), lastVisto.getInt(1));
                    int i = 0;
                    for (Serie serie : series) {
                        if (serie.equals(aux)) {
                            this.series.set(i, aux);
                        }
                        i++;
                    }
                } else {
                    this.series.add(aux);
                }
            }

        } catch (FileNotFoundException e) {

        }
    } catch (ClassNotFoundException ex) {
        ex.printStackTrace();
    }

}

From source file:edu.clemson.cs.nestbed.server.management.instrumentation.ProgramProbeManagerImpl.java

@SuppressWarnings("unchecked")
private StaticProgramData readStaticData(File file) throws IOException, ClassNotFoundException {
    StaticProgramData data;//from w w w  .  ja v a  2  s. co  m

    ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));

    data = new StaticProgramData((List<TraceModuleRecord>) in.readObject(),
            (List<TraceFunctionRecord>) in.readObject(),
            (Map<FunctionRecord, List<FunctionCalleeRecord>>) in.readObject(),
            (List<WiringRecord>) in.readObject());

    in.close();

    return data;
}

From source file:gr.wavesoft.webng.io.cache.DiskCacheStorage.java

private HttpCacheEntry unserialize(byte[] bytes, String key) {
    try {//from   ww  w . j a va2s.  c  o  m
        InputStream is = new ByteArrayInputStream(bytes);
        ObjectInputStream ois = new ObjectInputStream(is);

        // Read data
        Date dReq = new Date(ois.readLong());
        Date dRes = new Date(ois.readLong());
        StatusLine statusLine = (StatusLine) ois.readObject();
        Header[] responseHeaders = (Header[]) ois.readObject();

        // Close streams
        ois.close();
        is.close();

        // Build response
        HttpCacheEntry hce = new HttpCacheEntry(dReq, dRes, statusLine, responseHeaders,
                new FileResource(new File(baseDir + "/" + itemPrefix + key + ".cache")));

        return hce;

    } catch (ClassNotFoundException ex) {
        systemLogger.except(ex);
        return null;
    } catch (UnsupportedEncodingException ex) {
        systemLogger.except(ex);
        return null;
    } catch (IOException ex) {
        systemLogger.except(ex);
        return null;
    }
}

From source file:com.orange.matosweb.MatosCampaign.java

/**
 * Read back steps.//from w ww  .j  a v a 2 s .co  m
 */
@SuppressWarnings("unchecked")
private void restore() {
    try {
        File file = new File(privateFolder, BACKUP);
        if (!file.exists())
            return;
        FileInputStream fis = new FileInputStream(file);

        try {
            ObjectInputStream ois = new ObjectInputStream(fis);
            try {
                steps.addAll((List<MatosStep>) ois.readObject());
            } finally {
                ois.close();
            }
        } finally {
            fis.close();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.vkassin.mtrade.Common.java

public static void loadFavrList() {

    FileInputStream fileInputStream;
    try {/*from   w w w  . j av  a2 s  .c  om*/

        fileInputStream = app_ctx.openFileInput(FLIST_FNAME);
        ObjectInputStream oInputStream = new ObjectInputStream(fileInputStream);
        Object one = oInputStream.readObject();
        favrList = (HashSet<String>) one;
        oInputStream.close();
        fileInputStream.close();

    } catch (FileNotFoundException e) {

        // e.printStackTrace();
        Log.i(TAG, "creates blank. no file " + FLIST_FNAME);
        favrList = new HashSet<String>();

    } catch (StreamCorruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    // return favourites;
}

From source file:com.crispico.flower.mp.model.codesync.impl.FeatureChangeImpl.java

/**
 * Transient and lazy initialized on first access, by converting <code>*valueAsString</code>
 * to Object (using the current feature).
 * //from ww w.  j av  a2 s.  c  om
 * @generated NOT
 * @author Cristi
 * @author Mariana
 */
public Object getOldValue() {
    if (oldValue == null) {
        EDataType eDataTypeOfFeature = getEDataTypeOfFeature();
        if (eDataTypeOfFeature != null && !isMany()) {
            oldValue = EcoreUtil.createFromString(eDataTypeOfFeature, getOldValueAsString());
        } else {
            if (getOldValueAsString() == null) {
                oldValue = getOldValueAsContainmentList();
            } else {
                try {
                    ByteArrayInputStream input = new ByteArrayInputStream(
                            decode(getOldValueAsString().getBytes()));
                    ObjectInputStream ois = new ObjectInputStream(input);
                    oldValue = ois.readObject();
                    ois.close();
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
    return oldValue;
}

From source file:com.crispico.flower.mp.model.codesync.impl.FeatureChangeImpl.java

/**
 * Transient and lazy initialized on first access, by converting <code>*valueAsString</code>
 * to Object (using the current feature).
 * // w w  w.ja va 2 s . c om
 * @generated NOT
 * @author Cristi
 * @author Mariana
 */
public Object getNewValue() {
    if (newValue == null) {
        EDataType eDataTypeOfFeature = getEDataTypeOfFeature();
        if (eDataTypeOfFeature != null && !isMany()) {
            newValue = EcoreUtil.createFromString(eDataTypeOfFeature, getNewValueAsString());
        } else {
            if (getNewValueAsString() == null) {
                newValue = getNewValueAsContainmentList();
            } else {
                try {
                    ByteArrayInputStream input = new ByteArrayInputStream(
                            decode(getNewValueAsString().getBytes()));
                    ObjectInputStream ois = new ObjectInputStream(input);
                    newValue = ois.readObject();
                    ois.close();
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
    return newValue;
}

From source file:com.vkassin.mtrade.Common.java

public static void loadAccountDetails() {

    FileInputStream fileInputStream;
    try {//from   w  w w  .j a  v a 2  s  . com

        fileInputStream = app_ctx.openFileInput(ACCOUNT_FNAME);
        ObjectInputStream oInputStream = new ObjectInputStream(fileInputStream);
        Object one = oInputStream.readObject();
        myaccount = (HashMap<String, String>) one;
        oInputStream.close();
        fileInputStream.close();

    } catch (FileNotFoundException e) {

        // e.printStackTrace();
        Log.i(TAG, "No account file " + ACCOUNT_FNAME);

    } catch (StreamCorruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    // return favourites;
}

From source file:com.vkassin.mtrade.Common.java

public static void loadArcDeals() {

    FileInputStream fileInputStream;
    try {/*from   ww  w  . jav  a2s  .  com*/

        fileInputStream = app_ctx.openFileInput(ARCDEAL_FNAME);
        ObjectInputStream oInputStream = new ObjectInputStream(fileInputStream);
        Object one = oInputStream.readObject();
        arcdealMap = (HashMap<String, Deal>) one;
        oInputStream.close();
        fileInputStream.close();

    } catch (FileNotFoundException e) {

        // e.printStackTrace();
        Log.i(TAG, "creates blank. no file " + ARCDEAL_FNAME);
        arcdealMap = new HashMap<String, Deal>();

    } catch (StreamCorruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    // return favourites;
}

From source file:com.inmobi.grill.driver.hive.TestRemoteHiveDriver.java

private QueryContext readContext(byte[] bytes, GrillDriver driver) throws IOException, ClassNotFoundException {
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    ObjectInputStream in = new ObjectInputStream(bais);
    QueryContext ctx;/*from w w w. ja v a 2s  . co m*/
    try {
        ctx = (QueryContext) in.readObject();
        boolean driverAvailable = in.readBoolean();
        if (driverAvailable) {
            String clsName = in.readUTF();
            ctx.setSelectedDriver(driver);
        }
    } finally {
        in.close();
        bais.close();
    }
    return ctx;
}