private static void writeMementoToDisk(XMLMemento memento) { IPath path = URLWaypointPlugin.getDefault().getStateLocation().append(URL_FILE); File mementoFile = path.toFile(); mementoFile.getParentFile().mkdirs(); try { FileOutputStream stream = new FileOutputStream(mementoFile); OutputStreamWriter writer = new OutputStreamWriter(stream, "utf-8"); // $NON-NLS-1$ memento.save(writer); writer.close(); } catch (IOException e) { e.printStackTrace(); } }
public static void deSerialize() { IPath path = URLWaypointPlugin.getDefault().getStateLocation().append(URL_FILE); File mementoFile = path.toFile(); if (mementoFile.exists()) { try { FileInputStream input = new FileInputStream(mementoFile); BufferedReader reader = new BufferedReader(new InputStreamReader(input, "utf-8")); // $NON-NLS-1$ IMemento memento = XMLMemento.createReadRoot(reader); restoreStateFromMemento(memento); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (WorkbenchException e) { e.printStackTrace(); } } }