Skip to content

mike-adamenko/preferencex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

preferencex

Utility library that extends Java Preferences API to work with file as the storage

Preferencex library implemented without any dependencies.

Usage

  • set the system property java.util.prefs.PreferencesFactory to com.github.adamenko.prefs.FilePreferencesFactory
  • The default properties file is [user.home]/.fileprefs, but may be overridden with the system property com.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

About

Library that extends Java Preferences API to work with file as the storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages