The Java Developers Almanac 1.4


Order this book from Amazon.

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

e406. Determining If a Preference Node Contains a Specific Key

You cannot save null as a preference value. Therefore, if you retrieve a value using a default value of null, and null is returned, you can assume that the key is not present.
    // Returns true if node contains the specified key; false otherwise.
    public static boolean contains(Preferences node, String key) {
        return node.get(key, null) != null;
    }

 Related Examples
e405. Saving and Retrieving a Preference Value
e407. Determining If a Preference Node Contains a Specific Value
e408. Removing a Preference from a Preference Node
e409. Getting and Setting Java Type Values in a Preference
e410. Getting the Maximum Size of a Preference Key and Value

See also: Events    Importing and Exporting    Nodes   


© 2002 Addison-Wesley.