/**
* @see org.newdawn.slick.muffin.Muffin#saveFile(java.util.HashMap, java.lang.String)
*/
public void saveFile(HashMap scoreMap, String fileName) throws IOException {
PersistenceService ps;
BasicService bs;
URL configURL;
try {
ps = (PersistenceService) ServiceManager
.lookup("javax.jnlp.PersistenceService");
bs = (BasicService) ServiceManager
.lookup("javax.jnlp.BasicService");
URL baseURL = bs.getCodeBase();
// System.out.println("CodeBase was " + baseURL);
configURL = new URL(baseURL, fileName);
} catch (Exception e) {
Log.error(e);
throw new IOException("Failed to save state: ");
}
try {
ps.delete(configURL);
} catch (Exception e) {
Log.info("No exisiting Muffin Found - First Save");
}
try {
ps.create(configURL, 1024); // 1024 bytes for our data
FileContents fc = ps.get(configURL);
DataOutputStream oos = new DataOutputStream(fc
.getOutputStream(false));
// scroll through hashMap and write key and value to file
Set keys = scoreMap.keySet(); // get the keys