Results 1 to 6 of 6

Thread: Preference Node in Java

  1. #1
    Join Date
    Jan 2009
    Posts
    61

    Preference Node in Java

    Hello, I am learning java programming language and while learning it, I am not able to understand the concept of the Preference Node in Java. I have tried it to learn from the internet, but I am not able to get the solution for it. If you are having any idea regarding it, then please help me to achieve it. Or if you know the source from which I can able to get the information about it. So, reply me about it.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Preference Node in Java

    A node is a hierarchical collection of preference data. This class allows applications to store and retrieve user and system preference and configuration data. This data is stored persistently in an implementation-dependent backing store. Typical implementations include flat files, OS-specific registries, directory servers and SQL databases. The user of this class needn't be concerned with details of the backing store. There are two separate trees of preference nodes, one for user preferences and one for system preferences. Each user has a separate user preference tree, and all users in a given system share the same system preference tree. The precise description of "user" and "system" will vary from implementation to implementation. Typical information stored in the user preference tree might include font choice, color choice, or preferred window location and size for a particular application. Typical information stored in the system preference tree might include installation configuration data for an application.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Preference Node in Java

    Hello, if you want to use the program from which you can able to get the solution for the preference node in java then you must need to make use of the below mentioned simplest code for it:
    Code:
    import java.util.prefs.*;
    import java.io.IOException;
    public class prefNode
    {
      public static void main(String[] args) throws IOException, BackingStoreException 
    { 
            Preferences.userRoot().node("Techarena Team");
            Preferences preferences = Preferences.userRoot();
            preferences.exportSubtree(System.out);
    }
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Preference Node in Java

    If you want to create a preference node in java then it is just needed to make use of the code below for getting the solution:
    Code:
    Preferences preferences = Preferences.systemNodeForPackage(java.lang.String.class); 
    preferences = Preferences.systemRoot().node("/java/lang/String"); 
    preferences = Preferences.systemRoot().node("/javax/swing"); 
    preferences = preferences.node("Test/html"); 
    preferences = Preferences.userNodeForPackage(com.Testing.TestClass.class); 
    preferences = Preferences.userRoot().node("/com/Testing"); 
    preferences = Preferences.userRoot().node("/javax/swing"); 
    preferences = preferences.node("Test/html");

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Preference Node in Java

    Hello, preference class in java provides different methods. Some of them are as below:
    • absolutePath()
    • addPreferenceChangeListener(PreferenceChangeListener pcl)
    • clear()
    • exportNode(OutputStream os)
    • flush()
    • importPreferences(InputStream is)
    • isUserNode()
    • put(String key, String value)
    • putInt(String key, int value)
    • putLong(String key, long value)
    • remove(String key)
    • removeNode()
    • sync()
    • systemRoot()
    • toString()
    • userRoot()

  6. #6
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Preference Node in Java

    Hi, If you want to achieve the node from the preference then you need to be use the code provided below:
    Code:
    import java.util.prefs.Preferences;
    public class TestPreference 
    {
      public static void main(String args[]) throws Exception 
    {
        Preferences preference = Preferences.userRoot();
        Preferences preference1 = preference.node("TestPreference");
        preference1.put("A", "a");
        preference1.put("B", "b");
        preference1.put("C", "c");
        System.out.println("userNodeForPackage: " + Preferences.userNodeForPackage(TestPreference.class));
    
      }
    }

Similar Threads

  1. Weapon Class Preference in Brink
    By Y-Maker in forum Video Games
    Replies: 5
    Last Post: 14-05-2011, 10:12 AM
  2. Preference option not working in Opera
    By Lilah in forum Technology & Internet
    Replies: 5
    Last Post: 14-02-2011, 10:31 PM
  3. How to remove a node from JTree in java program?
    By kamina23 in forum Software Development
    Replies: 4
    Last Post: 22-01-2010, 05:41 PM
  4. Replies: 5
    Last Post: 22-01-2010, 04:17 PM
  5. Converting CDATA Node into Text Node
    By Jagdish Gada in forum Software Development
    Replies: 3
    Last Post: 07-12-2009, 09:54 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,945,950.87845 seconds with 16 queries