The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.util.prefs  [18 examples] > Nodes  [7 examples]

e416. Retrieving the Parent and Child Nodes of a Preference Node

    // Get a node
    Preferences prefs = Preferences.userNodeForPackage(java.lang.String.class);
    
    // Get the parent
    Preferences node = prefs.parent();   // /java
    node = node.parent();                // null
    
    // Get the names for nodes under java.lang
    String[] names = null;
    try {
        names = prefs.childrenNames();
    } catch (BackingStoreException e) {
    }
    
    // Get the child nodes using the names
    for (int i=0; i<names.length; i++) {
        node = prefs.node(names[i]);
    }

 Related Examples
e411. Getting the Roots of the Preference Trees
e412. Creating a Preference Node
e413. Retrieving a Preference Node
e414. Removing a Preference Node
e415. Determining If a Preference Node Exists
e417. Finding a Preference in a Preference Tree

See also: Events    Importing and Exporting   


© 2002 Addison-Wesley.