Retrieving a Preference Node - Java Native OS

Java examples for Native OS:Preference

Description

Retrieving a Preference Node

Demo Code

import java.util.prefs.Preferences;

public class Main {

  public void main(String[] argv) {
    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");
  }//from  www  . j ava2  s  .c  om
}

Related Tutorials