Utility library that extends Java Preferences API to work with file as the storage
Preferencex library implemented without any dependencies.
- set the system property
java.util.prefs.PreferencesFactorytocom.github.adamenko.prefs.FilePreferencesFactory - The default properties file is
[user.home]/.fileprefs, but may be overridden with the system propertycom.github.adamenko.prefs.FilePreferencesFactory.file
Example:
System.setProperty("java.util.prefs.PreferencesFactory", FilePreferencesFactory.class.getName());
System.setProperty(SYSTEM_PROPERTY_FILE, "myprefs.txt");
Preferences p = Preferences.userNodeForPackage(this.getClass());
p.putBoolean("boolean.property", true);
p.put("string.property", "custom.property.value");
System.out.println("boolean.property: " + p.get("boolean.property", null));
System.out.println("string.property: " + p.get("string.property", null));
console output:
boolean.property: true
string.property: custom.property.value