PreferenceExample.java Source code

Java tutorial

Introduction

Here is the source code for PreferenceExample.java

Source

import java.util.prefs.Preferences;

public class PreferenceExample {
    public static void main(String args[]) throws Exception {
        Preferences prefsRoot = Preferences.userRoot();
        Preferences myPrefs = prefsRoot.node("PreferenceExample");

        myPrefs.put("A", "a");
        myPrefs.put("B", "b");
        myPrefs.put("C", "c");

        System.out.println("Node's name: " + myPrefs.name());
        System.out.println("Node's parent: " + myPrefs.parent());
        System.out.println("NODE: " + myPrefs);

    }
}