Code example for ObjectInputStream

Methods: close, readObject

0
    public Object readObject(String fname) {
        FileInputStream fin = getFin(fname);
        if (fin == null)
            return null; 
        try { 
            ObjectInputStream din = new ObjectInputStream(fin);
            Object o = din.readObject();
            din.close();
            return o;
        } catch (IOException e) {
            Log.e(this.getClass().getName(), "Could not read object from "
                    + fname + "!");
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            Log.e(this.getClass().getName(),
                    "Could not find class: " + e.getMessage()
                            + " reading from " + fname + "!");
            e.printStackTrace();
        } catch (Throwable th){
        	Log.e(this.getClass().getName(), "Problem reading object", th);
        }