Home Java Example Java Util Creating a Preference Node
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Creating a Preference Node

Advertisement
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.

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:

 

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 7, 2009

Ask Questions?    Discuss: Creating a Preference Node  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com