Swing Application Framework session store
I have been using the Swing Application Framework, and very pleased with开发者_开发知识库 its sessions state storage. I was wondering if it's possible to delete (clean up) the persisted states.
- of All dialog forms. or
- of specific dialog forms.
If not, has anyone found a clean way to achieve this (stored files aren't saved in the same location depending on the OS etc..).
Thanks
you can delete the corresponding file/s (forgot the exact details about the naming) via the LocalStorage, here's a code snippet I use (with bsaf, but didn't change much, afair)
/**
* Deletes the session state by deleting the file. Useful during development
* when restoring to old state is not always the desired behaviour.
* Pending: this is incomplete, deletes the mainframe state only.
*/
protected void deleteSessionState() {
ApplicationContext context = getContext();
try {
context.getLocalStorage().deleteFile("mainFrame.session.xml");
} catch (...) {
}
}
File directory = context.getLocalStorage().getDirectory();
directory = directory.getCanonicalFile();
Files.deleteDirectoryContents(directory);
Files
is the google io lib.
精彩评论