public void load() { try { InputStream is = new BufferedInputStream(mContext.openFileInput(FILE_NAME), 8192); DataInputStream in = new DataInputStream(is); int version = in.readInt(); if (version > LAST_VERSION) { throw new IOException("data version " + version + "; expected " + LAST_VERSION); } if (version > 1) { mDeleteMode = in.readInt(); } if (version > 2) { int quickSerializable = in.readInt(); for (Base m : Base.values()) { if (m.getQuickSerializable() == quickSerializable) this.mMode = m; } } mHistory = new History(version, in); in.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public void save() { try { OutputStream os = new BufferedOutputStream(mContext.openFileOutput(FILE_NAME, 0), 8192); DataOutputStream out = new DataOutputStream(os); out.writeInt(LAST_VERSION); out.writeInt(mDeleteMode); out.writeInt( mMode == null ? Base.DECIMAL.getQuickSerializable() : mMode.getQuickSerializable()); mHistory.write(out); out.close(); } catch (IOException e) { e.printStackTrace(); } }