source.save(appTitle); } catch (BackingStoreException ex) { logger.log(Level.WARNING,
settings.save(baos); } catch (IOException ex) { ex.printStackTrace();
/** * Tests preference based AppSettings. */ private static void testPreferenceSettings() { AppSettings settings = new AppSettings(false); settings.putBoolean("TestBool", true); settings.putInteger("TestInt", 123); settings.putString("TestStr", "HelloWorld"); settings.putFloat("TestFloat", 123.567f); settings.put("TestObj", new Mesh()); // Objects not supported by preferences try { settings.save(APPSETTINGS_KEY); } catch (BackingStoreException ex) { ex.printStackTrace(); } AppSettings loadedSettings = new AppSettings(false); try { loadedSettings.load(APPSETTINGS_KEY); } catch (BackingStoreException ex) { ex.printStackTrace(); } assertEqual(loadedSettings.getBoolean("TestBool"), true); assertEqual(loadedSettings.getInteger("TestInt"), 123); assertEqual(loadedSettings.getString("TestStr"), "HelloWorld"); assertEqual(loadedSettings.get("TestFloat"), 123.567f); }
/** * Save the settings * * @throws java.io.IOException may fail to save */ public void save() throws IOException { try (OutputStream os = new FileOutputStream(new File(USER_SETTINGS_FILE))) { settings.save(os); } }
public void saveSettings() { try (OutputStream os = new FileOutputStream(new File(SETTINGS_FILE))) { settings.save(os); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.WARNING, "Settings file failed to save!", ex); } } }
source.save(appTitle); } catch (BackingStoreException ex) { logger.log(Level.WARNING,
source.save(appTitle); } catch (BackingStoreException ex) { logger.log(Level.WARNING,