Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.prefs.Preferences;

public class Main {
    public static void main(String[] argv) throws Exception {
        // System preference nodes

        // Use a Class
        Preferences prefs = Preferences.systemNodeForPackage(java.lang.String.class);

        // Use an absolute path
        prefs = Preferences.systemRoot().node("/java/lang/String");

        // Use a relative path
        prefs = Preferences.systemRoot().node("/javax/swing");
        prefs = prefs.node("text/html");

        // User preference nodes

        // Use a class
        prefs = Preferences.userNodeForPackage(Main.class);

        // Use an absolute path
        prefs = Preferences.userRoot().node("/com/mycompany");

        // Use a relative path
        prefs = Preferences.userRoot().node("/javax/swing");
        prefs = prefs.node("text/html");
    }
}