List of usage examples for java.util.prefs Preferences putLong
public abstract void putLong(String key, long value);
From source file:Main.java
public static void main(String[] argv) throws Exception { Preferences prefs = Preferences.userNodeForPackage(String.class); // Save some values prefs.put("myString", "a string"); // String prefs.putBoolean("myBoolean", true); // boolean prefs.putInt("myInt", 123); // int prefs.putLong("myLong", 123L); // long prefs.putFloat("myFloat", 12.3F); // float prefs.putDouble("myDouble", 12.3); // double byte[] bytes = new byte[10]; prefs.putByteArray("myByteArray", bytes); // byte[] // Export the node to a file prefs.exportNode(new FileOutputStream("output.xml")); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Preferences prefs = Preferences.userNodeForPackage(String.class); // Save some values prefs.put("myString", "a string"); // String prefs.putBoolean("myBoolean", true); // boolean prefs.putInt("myInt", 123); // int prefs.putLong("myLong", 123L); // long // Save some values in the parent node prefs = prefs.parent();// w w w . j a v a 2 s .co m prefs.putFloat("myFloat", 12.3F); // float prefs.putDouble("myDouble", 12.3); // double byte[] bytes = new byte[10]; prefs.putByteArray("myByteArray", bytes); // byte[] prefs.exportSubtree(new FileOutputStream("output.xml")); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Preferences prefs = Preferences.userNodeForPackage(Main.class); // Preference key name final String PREF_NAME = "name_of_preference"; // Save/*from w w w . j ava 2 s . c o m*/ prefs.put(PREF_NAME, "a string"); // String prefs.putBoolean(PREF_NAME, true); // boolean prefs.putInt(PREF_NAME, 123); // int prefs.putLong(PREF_NAME, 123L); // long prefs.putFloat(PREF_NAME, 12.3F); // float prefs.putDouble(PREF_NAME, 12.3); // double byte[] bytes = new byte[1024]; prefs.putByteArray(PREF_NAME, bytes); // byte[] // Retrieve String s = prefs.get(PREF_NAME, "a string"); // String boolean b = prefs.getBoolean(PREF_NAME, true); // boolean int i = prefs.getInt(PREF_NAME, 123); // int long l = prefs.getLong(PREF_NAME, 123L); // long float f = prefs.getFloat(PREF_NAME, 12.3F); // float double d = prefs.getDouble(PREF_NAME, 12.3); // double bytes = prefs.getByteArray(PREF_NAME, bytes); // byte[] }
From source file:org.pdfsam.module.PreferencesUsageDataStore.java
private void incrementTotalUsage() { Preferences node = Preferences.userRoot().node(USAGE_PATH); node.putLong(TASKS_EXECUTED_KEY, node.getLong(TASKS_EXECUTED_KEY, 0) + 1); }
From source file:de.innovationgate.wgpublisher.WGACore.java
private void setLastCharacterEncoding(String characterEncoding) { Preferences prefs = Preferences.userNodeForPackage(this.getClass()); prefs.put("LastCharacterEncoding", characterEncoding); prefs.putLong("CharacterEncodingModified", System.currentTimeMillis()); }
From source file:de.innovationgate.wgpublisher.WGACore.java
private void setLastDesignEncoding(String dbkey, String encoding) { try {// w ww . j av a 2 s.com Preferences prefs = Preferences.userNodeForPackage(this.getClass()); prefs.put(createPrefKeyDesignEncoding(dbkey), encoding); prefs.putLong(createPrefKeyDesignEncodingLastModified(dbkey), System.currentTimeMillis()); } catch (Exception e) { log.error("Unable to set lastDesignEncoding preferences.", e); } }