Getting the Roots of the Preference Trees - Java Native OS

Java examples for Native OS:Preference

Description

Getting the Roots of the Preference Trees

Demo Code

import java.util.prefs.Preferences;

public class Main {
  public static void main(String[] argv) {
    // Get the system root
    Preferences prefs = Preferences.systemRoot();

    // Get the user root
    prefs = Preferences.userRoot();

    // The name of a root is ""
    String name = prefs.name();/*from   w w  w. j a va  2 s  .c o  m*/

    // The parent of a root is null
    Preferences parent = prefs.parent();

    // The absolute path of a root is "/"
    String path = prefs.absolutePath();
  }
}

Result


Related Tutorials