[an error occurred while processing this directive]

Creating a Preference Node

                         

This section demonstrates you to create a Preference Node in C. As you know that there are two types of Preference nodes, User Preference Node and System Preference Node. Here we are going to create a user preference node. The method userRoot() provided by the Preferences class returns the root preference node for the calling user and node("/Roseindia Employees") method creates the specified node if the node does not exists. In order to show the created node in the Preference tree, we have used the method exportSubtree()  which emits an XML document representing all of the preferences contained in the node and all of its descendants on the console.

Here is the code:

 

 

 

 

import java.util.prefs.*;
import java.io.IOException;
public class CreateNode{
  public static void main(String[] args) throws IOException, BackingStoreException { 
        Preferences.userRoot().node("/Roseindia Employees");
        Preferences root = Preferences.userRoot();
        root.exportSubtree(System.out);
  }
   }

Output will be displayed as:

Download Source Code:

 

                         

[an error occurred while processing this directive]