views:

1522

answers:

2

I want to use the java.util.Preferences API but I don't want my program to attempt to read or write to the Windows registry. How would I go about this?

A: 

It is always possible to extend java.util.prefs.AbstractPreferences.

An alternative could be to use The Configuration package of Apache Commons allows you to read and write configuration data from/to different sources.

Ruben
+6  A: 

I trust you have read the read/write to Windows Registry using Java and you then want to have another back-end than the registry when using the java.util.Preferences API

As this gentleman, you could extend the Preference API

As specified in this java sun article:

Because the Preferences API is back-end neutral, you need not care whether the data are stored in files, database tables, or a platform-specific storage such as the Windows Registry.

An example of such an extension through a new PreferenceFactory can be seen here.

That is better, IMO, than to use another API.

VonC
Good stuff, thanks. Note that you can se the PreferencesFactory to be used with the Java system property "java.util.prefs.PreferencesFactory". http://www.onjava.com/pub/a/onjava/synd/2001/10/17/j2se.html?page=2
Epaga