import java.util.prefs.Preferences;
public class MainClass {
public static void main(String[] args) {
// Setup the Preferences for this application, by class.
Preferences prefs = Preferences.userNodeForPackage(MainClass.class);
// Retrieve some preferences previously stored, with defaults in case
// this is the first run.
String text = prefs.get("A", "a");
String display = prefs.get("B", "b");
System.out.println(text);
System.out.println(display);
// Assume the user chose new preference values: Store them back.
prefs.put("A", "aa");
prefs.put("B", "bb");
}
}
|