java.util.prefs
Class Preferences

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.util.prefs.Preferences
Direct Known Subclasses:
AbstractPreferences sample code for java.util.prefs.AbstractPreferences definition code for java.util.prefs.AbstractPreferences

public abstract class Preferences
extends Object sample code for java.lang.Object definition code for java.lang.Object

A node in 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.

Nodes in a preference tree are named in a similar fashion to directories in a hierarchical file system. Every node in a preference tree has a node name (which is not necessarily unique), a unique absolute path name, and a path name relative to each ancestor including itself.

The root node has a node name of the empty string (""). Every other node has an arbitrary node name, specified at the time it is created. The only restrictions on this name are that it cannot be the empty string, and it cannot contain the slash character ('/').

The root node has an absolute path name of "/". Children of the root node have absolute path names of "/" + <node name>. All other nodes have absolute path names of <parent's absolute path name> + "/" + <node name>. Note that all absolute path names begin with the slash character.

A node n's path name relative to its ancestor a is simply the string that must be appended to a's absolute path name in order to form n's absolute path name, with the initial slash character (if present) removed. Note that:

Note finally that:

All of the methods that modify preferences data are permitted to operate asynchronously; they may return immediately, and changes will eventually propagate to the persistent backing store with an implementation-dependent delay. The flush method may be used to synchronously force updates to the backing store. Normal termination of the Java Virtual Machine will not result in the loss of pending updates -- an explicit flush invocation is not required upon termination to ensure that pending updates are made persistent.

All of the methods that read preferences from a Preferences object require the invoker to provide a default value. The default value is returned if no value has been previously set or if the backing store is unavailable. The intent is to allow applications to operate, albeit with slightly degraded functionality, even if the backing store becomes unavailable. Several methods, like flush, have semantics that prevent them from operating if the backing store is unavailable. Ordinary applications should have no need to invoke any of these methods, which can be identified by the fact that they are declared to throw BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException .

The methods in this class may be invoked concurrently by multiple threads in a single JVM without the need for external synchronization, and the results will be equivalent to some serial execution. If this class is used concurrently by multiple JVMs that store their preference data in the same backing store, the data store will not be corrupted, but no other guarantees are made concerning the consistency of the preference data.

This class contains an export/import facility, allowing preferences to be "exported" to an XML document, and XML documents representing preferences to be "imported" back into the system. This facility may be used to back up all or part of a preference tree, and subsequently restore from the backup.

The XML document has the following DOCTYPE declaration:

 <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
 
Note that the system URI (http://java.sun.com/dtd/preferences.dtd) is not accessed when exporting or importing preferences; it merely serves as a string to uniquely identify the DTD, which is:
    <?xml version="1.0" encoding="UTF-8"?>

    <!-- DTD for a Preferences tree. -->

    <!-- The preferences element is at the root of an XML document
         representing a Preferences tree. -->
    <!ELEMENT preferences (root)>
  
    <!-- The preferences element contains an optional version attribute,
          which specifies version of DTD. -->
    <!ATTLIST preferences EXTERNAL_XML_VERSION CDATA "0.0" >  

    <!-- The root element has a map representing the root's preferences
         (if any), and one node for each child of the root (if any). -->
    <!ELEMENT root (map, node*) >

    <!-- Additionally, the root contains a type attribute, which
         specifies whether it's the system or user root. -->
    <!ATTLIST root
              type (system|user) #REQUIRED >

    <!-- Each node has a map representing its preferences (if any),
         and one node for each child (if any). -->
    <!ELEMENT node (map, node*) >

    <!-- Additionally, each node has a name attribute -->
    <!ATTLIST node
              name CDATA #REQUIRED >

    <!-- A map represents the preferences stored at a node (if any). -->
    <!ELEMENT map (entry*) >

    <!-- An entry represents a single preference, which is simply
          a key-value pair. -->
    <!ELEMENT entry EMPTY >
    <!ATTLIST entry
              key   CDATA #REQUIRED
              value CDATA #REQUIRED >
 
Every Preferences implementation must have an associated PreferencesFactory sample code for java.util.prefs.PreferencesFactory definition code for java.util.prefs.PreferencesFactory implementation. Every J2SE implementation must provide some means of specifying which PreferencesFactory implementation is used to generate the root preferences nodes. This allows the administrator to replace the default preferences implementation with an alternative implementation.

Implementation note: In Sun's JRE, the PreferencesFactory implementation is located as follows:

  1. If the system property java.util.prefs.PreferencesFactory is defined, then it is taken to be the fully-qualified name of a class implementing the PreferencesFactory interface. The class is loaded and instantiated; if this process fails then an unspecified error is thrown.

  2. If a PreferencesFactory implementation class file has been installed in a jar file that is visible to the system class loader sample code for java.lang.ClassLoader.getSystemClassLoader() definition code for java.lang.ClassLoader.getSystemClassLoader() , and that jar file contains a provider-configuration file named java.util.prefs.PreferencesFactory in the resource directory META-INF/services, then the first class name specified in that file is taken. If more than one such jar file is provided, the first one found will be used. The class is loaded and instantiated; if this process fails then an unspecified error is thrown.

  3. Finally, if neither the above-mentioned system property nor an extension jar file is provided, then the system-wide default PreferencesFactory implementation for the underlying platform is loaded and instantiated.

Since:
1.4

Field Summary
static int MAX_KEY_LENGTH sample code for java.util.prefs.Preferences.MAX_KEY_LENGTH definition code for java.util.prefs.Preferences.MAX_KEY_LENGTH
          Maximum length of string allowed as a key (80 characters).
static int MAX_NAME_LENGTH sample code for java.util.prefs.Preferences.MAX_NAME_LENGTH definition code for java.util.prefs.Preferences.MAX_NAME_LENGTH
          Maximum length of a node name (80 characters).
static int MAX_VALUE_LENGTH sample code for java.util.prefs.Preferences.MAX_VALUE_LENGTH definition code for java.util.prefs.Preferences.MAX_VALUE_LENGTH
          Maximum length of string allowed as a value (8192 characters).
 
Constructor Summary
protected Preferences sample code for java.util.prefs.Preferences.Preferences() definition code for java.util.prefs.Preferences.Preferences() ()
          Sole constructor.
 
Method Summary
abstract  String sample code for java.lang.String definition code for java.lang.String absolutePath sample code for java.util.prefs.Preferences.absolutePath() definition code for java.util.prefs.Preferences.absolutePath() ()
          Returns this preference node's absolute path name.
abstract  void addNodeChangeListener sample code for java.util.prefs.Preferences.addNodeChangeListener(java.util.prefs.NodeChangeListener) definition code for java.util.prefs.Preferences.addNodeChangeListener(java.util.prefs.NodeChangeListener) (NodeChangeListener sample code for java.util.prefs.NodeChangeListener definition code for java.util.prefs.NodeChangeListener  ncl)
          Registers the specified listener to receive node change events for this node.
abstract  void addPreferenceChangeListener sample code for java.util.prefs.Preferences.addPreferenceChangeListener(java.util.prefs.PreferenceChangeListener) definition code for java.util.prefs.Preferences.addPreferenceChangeListener(java.util.prefs.PreferenceChangeListener) (PreferenceChangeListener sample code for java.util.prefs.PreferenceChangeListener definition code for java.util.prefs.PreferenceChangeListener  pcl)
          Registers the specified listener to receive preference change events for this preference node.
abstract  String sample code for java.lang.String definition code for java.lang.String [] childrenNames sample code for java.util.prefs.Preferences.childrenNames() definition code for java.util.prefs.Preferences.childrenNames() ()
          Returns the names of the children of this preference node, relative to this node.
abstract  void clear sample code for java.util.prefs.Preferences.clear() definition code for java.util.prefs.Preferences.clear() ()
          Removes all of the preferences (key-value associations) in this preference node.
abstract  void exportNode sample code for java.util.prefs.Preferences.exportNode(java.io.OutputStream) definition code for java.util.prefs.Preferences.exportNode(java.io.OutputStream) (OutputStream sample code for java.io.OutputStream definition code for java.io.OutputStream  os)
          Emits on the specified output stream an XML document representing all of the preferences contained in this node (but not its descendants).
abstract  void exportSubtree sample code for java.util.prefs.Preferences.exportSubtree(java.io.OutputStream) definition code for java.util.prefs.Preferences.exportSubtree(java.io.OutputStream) (OutputStream sample code for java.io.OutputStream definition code for java.io.OutputStream  os)
          Emits an XML document representing all of the preferences contained in this node and all of its descendants.
abstract  void flush sample code for java.util.prefs.Preferences.flush() definition code for java.util.prefs.Preferences.flush() ()
          Forces any changes in the contents of this preference node and its descendants to the persistent store.
abstract  String sample code for java.lang.String definition code for java.lang.String get sample code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String) definition code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  key, String sample code for java.lang.String definition code for java.lang.String  def)
          Returns the value associated with the specified key in this preference node.
abstract  boolean getBoolean sample code for java.util.prefs.Preferences.getBoolean(java.lang.String, boolean) definition code for java.util.prefs.Preferences.getBoolean(java.lang.String, boolean) (String sample code for java.lang.String definition code for java.lang.String  key, boolean def)
          Returns the boolean value represented by the string associated with the specified key in this preference node.
abstract  byte[] getByteArray sample code for java.util.prefs.Preferences.getByteArray(java.lang.String, byte[]) definition code for java.util.prefs.Preferences.getByteArray(java.lang.String, byte[]) (String sample code for java.lang.String definition code for java.lang.String  key, byte[] def)
          Returns the byte array value represented by the string associated with the specified key in this preference node.
abstract  double getDouble sample code for java.util.prefs.Preferences.getDouble(java.lang.String, double) definition code for java.util.prefs.Preferences.getDouble(java.lang.String, double) (String sample code for java.lang.String definition code for java.lang.String  key, double def)
          Returns the double value represented by the string associated with the specified key in this preference node.
abstract  float getFloat sample code for java.util.prefs.Preferences.getFloat(java.lang.String, float) definition code for java.util.prefs.Preferences.getFloat(java.lang.String, float) (String sample code for java.lang.String definition code for java.lang.String  key, float def)
          Returns the float value represented by the string associated with the specified key in this preference node.
abstract  int getInt sample code for java.util.prefs.Preferences.getInt(java.lang.String, int) definition code for java.util.prefs.Preferences.getInt(java.lang.String, int) (String sample code for java.lang.String definition code for java.lang.String  key, int def)
          Returns the int value represented by the string associated with the specified key in this preference node.
abstract  long getLong sample code for java.util.prefs.Preferences.getLong(java.lang.String, long) definition code for java.util.prefs.Preferences.getLong(java.lang.String, long) (String sample code for java.lang.String definition code for java.lang.String  key, long def)
          Returns the long value represented by the string associated with the specified key in this preference node.
static void importPreferences sample code for java.util.prefs.Preferences.importPreferences(java.io.InputStream) definition code for java.util.prefs.Preferences.importPreferences(java.io.InputStream) (InputStream sample code for java.io.InputStream definition code for java.io.InputStream  is)
          Imports all of the preferences represented by the XML document on the specified input stream.
abstract  boolean isUserNode sample code for java.util.prefs.Preferences.isUserNode() definition code for java.util.prefs.Preferences.isUserNode() ()
          Returns true if this preference node is in the user preference tree, false if it's in the system preference tree.
abstract  String sample code for java.lang.String definition code for java.lang.String [] keys sample code for java.util.prefs.Preferences.keys() definition code for java.util.prefs.Preferences.keys() ()
          Returns all of the keys that have an associated value in this preference node.
abstract  String sample code for java.lang.String definition code for java.lang.String name sample code for java.util.prefs.Preferences.name() definition code for java.util.prefs.Preferences.name() ()
          Returns this preference node's name, relative to its parent.
abstract  Preferences sample code for java.util.prefs.Preferences definition code for java.util.prefs.Preferences node sample code for java.util.prefs.Preferences.node(java.lang.String) definition code for java.util.prefs.Preferences.node(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  pathName)
          Returns the named preference node in the same tree as this node, creating it and any of its ancestors if they do not already exist.
abstract  boolean nodeExists sample code for java.util.prefs.Preferences.nodeExists(java.lang.String) definition code for java.util.prefs.Preferences.nodeExists(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  pathName)
          Returns true if the named preference node exists in the same tree as this node.
abstract  Preferences sample code for java.util.prefs.Preferences definition code for java.util.prefs.Preferences parent sample code for java.util.prefs.Preferences.parent() definition code for java.util.prefs.Preferences.parent() ()
          Returns the parent of this preference node, or null if this is the root.
abstract  void put sample code for java.util.prefs.Preferences.put(java.lang.String, java.lang.String) definition code for java.util.prefs.Preferences.put(java.lang.String, java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  key, String sample code for java.lang.String definition code for java.lang.String  value)
          Associates the specified value with the specified key in this preference node.
abstract  void putBoolean sample code for java.util.prefs.Preferences.putBoolean(java.lang.String, boolean) definition code for java.util.prefs.Preferences.putBoolean(java.lang.String, boolean) (String sample code for java.lang.String definition code for java.lang.String  key, boolean value)
          Associates a string representing the specified boolean value with the specified key in this preference node.
abstract  void putByteArray sample code for java.util.prefs.Preferences.putByteArray(java.lang.String, byte[]) definition code for java.util.prefs.Preferences.putByteArray(java.lang.String, byte[]) (String sample code for java.lang.String definition code for java.lang.String  key, byte[] value)
          Associates a string representing the specified byte array with the specified key in this preference node.
abstract  void putDouble sample code for java.util.prefs.Preferences.putDouble(java.lang.String, double) definition code for java.util.prefs.Preferences.putDouble(java.lang.String, double) (String sample code for java.lang.String definition code for java.lang.String  key, double value)
          Associates a string representing the specified double value with the specified key in this preference node.
abstract  void putFloat sample code for java.util.prefs.Preferences.putFloat(java.lang.String, float) definition code for java.util.prefs.Preferences.putFloat(java.lang.String, float) (String sample code for java.lang.String definition code for java.lang.String  key, float value)
          Associates a string representing the specified float value with the specified key in this preference node.
abstract  void putInt sample code for java.util.prefs.Preferences.putInt(java.lang.String, int) definition code for java.util.prefs.Preferences.putInt(java.lang.String, int) (String sample code for java.lang.String definition code for java.lang.String  key, int value)
          Associates a string representing the specified int value with the specified key in this preference node.
abstract  void putLong sample code for java.util.prefs.Preferences.putLong(java.lang.String, long) definition code for java.util.prefs.Preferences.putLong(java.lang.String, long) (String sample code for java.lang.String definition code for java.lang.String  key, long value)
          Associates a string representing the specified long value with the specified key in this preference node.
abstract  void remove sample code for java.util.prefs.Preferences.remove(java.lang.String) definition code for java.util.prefs.Preferences.remove(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  key)
          Removes the value associated with the specified key in this preference node, if any.
abstract  void removeNode sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() ()
          Removes this preference node and all of its descendants, invalidating any preferences contained in the removed nodes.
abstract  void removeNodeChangeListener sample code for java.util.prefs.Preferences.removeNodeChangeListener(java.util.prefs.NodeChangeListener) definition code for java.util.prefs.Preferences.removeNodeChangeListener(java.util.prefs.NodeChangeListener) (NodeChangeListener sample code for java.util.prefs.NodeChangeListener definition code for java.util.prefs.NodeChangeListener  ncl)
          Removes the specified NodeChangeListener, so it no longer receives change events.
abstract  void removePreferenceChangeListener sample code for java.util.prefs.Preferences.removePreferenceChangeListener(java.util.prefs.PreferenceChangeListener) definition code for java.util.prefs.Preferences.removePreferenceChangeListener(java.util.prefs.PreferenceChangeListener) (PreferenceChangeListener sample code for java.util.prefs.PreferenceChangeListener definition code for java.util.prefs.PreferenceChangeListener  pcl)
          Removes the specified preference change listener, so it no longer receives preference change events.
abstract  void sync sample code for java.util.prefs.Preferences.sync() definition code for java.util.prefs.Preferences.sync() ()
          Ensures that future reads from this preference node and its descendants reflect any changes that were committed to the persistent store (from any VM) prior to the sync invocation.
static Preferences sample code for java.util.prefs.Preferences definition code for java.util.prefs.Preferences systemNodeForPackage sample code for java.util.prefs.Preferences.systemNodeForPackage(java.lang.Class) definition code for java.util.prefs.Preferences.systemNodeForPackage(java.lang.Class) (Class sample code for java.lang.Class definition code for java.lang.Class <?> c)
          Returns the preference node from the system preference tree that is associated (by convention) with the specified class's package.
static Preferences sample code for java.util.prefs.Preferences definition code for java.util.prefs.Preferences systemRoot sample code for java.util.prefs.Preferences.systemRoot() definition code for java.util.prefs.Preferences.systemRoot() ()
          Returns the root preference node for the system.
abstract  String sample code for java.lang.String definition code for java.lang.String toString sample code for java.util.prefs.Preferences.toString() definition code for java.util.prefs.Preferences.toString() ()
          Returns a string representation of this preferences node, as if computed by the expression:(this.isUserNode() ? "User" : "System") + " Preference Node: " + this.absolutePath().
static Preferences sample code for java.util.prefs.Preferences definition code for java.util.prefs.Preferences userNodeForPackage sample code for java.util.prefs.Preferences.userNodeForPackage(java.lang.Class) definition code for java.util.prefs.Preferences.userNodeForPackage(java.lang.Class) (Class sample code for java.lang.Class definition code for java.lang.Class <?> c)
          Returns the preference node from the calling user's preference tree that is associated (by convention) with the specified class's package.
static Preferences sample code for java.util.prefs.Preferences definition code for java.util.prefs.Preferences userRoot sample code for java.util.prefs.Preferences.userRoot() definition code for java.util.prefs.Preferences.userRoot() ()
          Returns the root preference node for the calling user.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

MAX_KEY_LENGTH sample code for java.util.prefs.Preferences.MAX_KEY_LENGTH

public static final int MAX_KEY_LENGTH
Maximum length of string allowed as a key (80 characters).

See Also:
Constant Field Values

MAX_VALUE_LENGTH sample code for java.util.prefs.Preferences.MAX_VALUE_LENGTH

public static final int MAX_VALUE_LENGTH
Maximum length of string allowed as a value (8192 characters).

See Also:
Constant Field Values

MAX_NAME_LENGTH sample code for java.util.prefs.Preferences.MAX_NAME_LENGTH

public static final int MAX_NAME_LENGTH
Maximum length of a node name (80 characters).

See Also:
Constant Field Values
Constructor Detail

Preferences sample code for java.util.prefs.Preferences() definition code for java.util.prefs.Preferences()

protected Preferences()
Sole constructor. (For invocation by subclass constructors, typically implicit.)

Method Detail

userNodeForPackage sample code for java.util.prefs.Preferences.userNodeForPackage(java.lang.Class<?>) definition code for java.util.prefs.Preferences.userNodeForPackage(java.lang.Class<?>)

public static Preferences sample code for java.util.prefs.Preferences definition code for java.util.prefs.Preferences  userNodeForPackage(Class sample code for java.lang.Class definition code for java.lang.Class <?> c)
Returns the preference node from the calling user's preference tree that is associated (by convention) with the specified class's package. The convention is as follows: the absolute path name of the node is the fully qualified package name, preceded by a slash ('/'), and with each period ('.') replaced by a slash. For example the absolute path name of the node associated with the class com.acme.widget is /com/acme/widget.

This convention does not apply to the unnamed package, whose associated preference node is <unnamed>. This node is not intended for long term use, but for convenience in the early development of programs that do not yet belong to a package, and for "throwaway" programs. Valuable data should not be stored at this node as it is shared by all programs that use it.

A class Foo wishing to access preferences pertaining to its package can obtain a preference node as follows:

    static Preferences prefs = Preferences.userNodeForPackage(Foo.class);
 
This idiom obviates the need for using a string to describe the preferences node and decreases the likelihood of a run-time failure. (If the class name is misspelled, it will typically result in a compile-time error.)

Invoking this method will result in the creation of the returned node and its ancestors if they do not already exist. If the returned node did not exist prior to this call, this node and any ancestors that were created by this call are not guaranteed to become permanent until the flush method is called on the returned node (or one of its ancestors or descendants).

Parameters:
c - the class for whose package a user preference node is desired.
Returns:
the user preference node associated with the package of which c is a member.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if c is null.
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if a security manager is present and it denies RuntimePermission("preferences").
See Also:
RuntimePermission sample code for java.lang.RuntimePermission definition code for java.lang.RuntimePermission

systemNodeForPackage sample code for java.util.prefs.Preferences.systemNodeForPackage(java.lang.Class<?>) definition code for java.util.prefs.Preferences.systemNodeForPackage(java.lang.Class<?>)

public static Preferences sample code for java.util.prefs.Preferences definition code for java.util.prefs.Preferences  systemNodeForPackage(Class sample code for java.lang.Class definition code for java.lang.Class <?> c)
Returns the preference node from the system preference tree that is associated (by convention) with the specified class's package. The convention is as follows: the absolute path name of the node is the fully qualified package name, preceded by a slash ('/'), and with each period ('.') replaced by a slash. For example the absolute path name of the node associated with the class com.acme.widget is /com/acme/widget.

This convention does not apply to the unnamed package, whose associated preference node is <unnamed>. This node is not intended for long term use, but for convenience in the early development of programs that do not yet belong to a package, and for "throwaway" programs. Valuable data should not be stored at this node as it is shared by all programs that use it.

A class Foo wishing to access preferences pertaining to its package can obtain a preference node as follows:

  static Preferences prefs = Preferences.systemNodeForPackage(Foo.class);
 
This idiom obviates the need for using a string to describe the preferences node and decreases the likelihood of a run-time failure. (If the class name is misspelled, it will typically result in a compile-time error.)

Invoking this method will result in the creation of the returned node and its ancestors if they do not already exist. If the returned node did not exist prior to this call, this node and any ancestors that were created by this call are not guaranteed to become permanent until the flush method is called on the returned node (or one of its ancestors or descendants).

Parameters:
c - the class for whose package a system preference node is desired.
Returns:
the system preference node associated with the package of which c is a member.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if c is null.
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if a security manager is present and it denies RuntimePermission("preferences").
See Also:
RuntimePermission sample code for java.lang.RuntimePermission definition code for java.lang.RuntimePermission

userRoot sample code for java.util.prefs.Preferences.userRoot() definition code for java.util.prefs.Preferences.userRoot()

public static Preferences sample code for java.util.prefs.Preferences definition code for java.util.prefs.Preferences  userRoot()
Returns the root preference node for the calling user.

Returns:
the root preference node for the calling user.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - If a security manager is present and it denies RuntimePermission("preferences").
See Also:
RuntimePermission sample code for java.lang.RuntimePermission definition code for java.lang.RuntimePermission

systemRoot sample code for java.util.prefs.Preferences.systemRoot() definition code for java.util.prefs.Preferences.systemRoot()

public static Preferences sample code for java.util.prefs.Preferences definition code for java.util.prefs.Preferences  systemRoot()
Returns the root preference node for the system.

Returns:
the root preference node for the system.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - If a security manager is present and it denies RuntimePermission("preferences").
See Also:
RuntimePermission sample code for java.lang.RuntimePermission definition code for java.lang.RuntimePermission

put sample code for java.util.prefs.Preferences.put(java.lang.String, java.lang.String) definition code for java.util.prefs.Preferences.put(java.lang.String, java.lang.String)

public abstract void put(String sample code for java.lang.String definition code for java.lang.String  key,
                         String sample code for java.lang.String definition code for java.lang.String  value)
Associates the specified value with the specified key in this preference node.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key or value is null.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if key.length() exceeds MAX_KEY_LENGTH or if value.length exceeds MAX_VALUE_LENGTH.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.

get sample code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String) definition code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String)

public abstract String sample code for java.lang.String definition code for java.lang.String  get(String sample code for java.lang.String definition code for java.lang.String  key,
                           String sample code for java.lang.String definition code for java.lang.String  def)
Returns the value associated with the specified key in this preference node. Returns the specified default if there is no value associated with the key, or the backing store is inaccessible.

Some implementations may store default values in their backing stores. If there is no value associated with the specified key but there is such a stored default, it is returned in preference to the specified default.

Parameters:
key - key whose associated value is to be returned.
def - the value to be returned in the event that this preference node has no value associated with key.
Returns:
the value associated with key, or def if no value is associated with key, or the backing store is inaccessible.
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key is null. (A null value for def is permitted.)

remove sample code for java.util.prefs.Preferences.remove(java.lang.String) definition code for java.util.prefs.Preferences.remove(java.lang.String)

public abstract void remove(String sample code for java.lang.String definition code for java.lang.String  key)
Removes the value associated with the specified key in this preference node, if any.

If this implementation supports stored defaults, and there is such a default for the specified preference, the stored default will be "exposed" by this call, in the sense that it will be returned by a succeeding call to get.

Parameters:
key - key whose mapping is to be removed from the preference node.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key is null.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.

clear sample code for java.util.prefs.Preferences.clear() definition code for java.util.prefs.Preferences.clear()

public abstract void clear()
                    throws BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException 
Removes all of the preferences (key-value associations) in this preference node. This call has no effect on any descendants of this node.

If this implementation supports stored defaults, and this node in the preferences hierarchy contains any such defaults, the stored defaults will be "exposed" by this call, in the sense that they will be returned by succeeding calls to get.

Throws:
BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException - if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode()

putInt sample code for java.util.prefs.Preferences.putInt(java.lang.String, int) definition code for java.util.prefs.Preferences.putInt(java.lang.String, int)

public abstract void putInt(String sample code for java.lang.String definition code for java.lang.String  key,
                            int value)
Associates a string representing the specified int value with the specified key in this preference node. The associated string is the one that would be returned if the int value were passed to Integer.toString(int) sample code for java.lang.Integer.toString(int) definition code for java.lang.Integer.toString(int) . This method is intended for use in conjunction with getInt(java.lang.String, int) sample code for java.util.prefs.Preferences.getInt(java.lang.String, int) definition code for java.util.prefs.Preferences.getInt(java.lang.String, int) .

Parameters:
key - key with which the string form of value is to be associated.
value - value whose string form is to be associated with key.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key is null.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if key.length() exceeds MAX_KEY_LENGTH.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
getInt(String,int) sample code for java.util.prefs.Preferences.getInt(java.lang.String, int) definition code for java.util.prefs.Preferences.getInt(java.lang.String, int)

getInt sample code for java.util.prefs.Preferences.getInt(java.lang.String, int) definition code for java.util.prefs.Preferences.getInt(java.lang.String, int)

public abstract int getInt(String sample code for java.lang.String definition code for java.lang.String  key,
                           int def)
Returns the int value represented by the string associated with the specified key in this preference node. The string is converted to an integer as by Integer.parseInt(String) sample code for java.lang.Integer.parseInt(java.lang.String) definition code for java.lang.Integer.parseInt(java.lang.String) . Returns the specified default if there is no value associated with the key, the backing store is inaccessible, or if Integer.parseInt(String) would throw a NumberFormatException sample code for java.lang.NumberFormatException definition code for java.lang.NumberFormatException if the associated value were passed. This method is intended for use in conjunction with putInt(java.lang.String, int) sample code for java.util.prefs.Preferences.putInt(java.lang.String, int) definition code for java.util.prefs.Preferences.putInt(java.lang.String, int) .

If the implementation supports stored defaults and such a default exists, is accessible, and could be converted to an int with Integer.parseInt, this int is returned in preference to the specified default.

Parameters:
key - key whose associated value is to be returned as an int.
def - the value to be returned in the event that this preference node has no value associated with key or the associated value cannot be interpreted as an int, or the backing store is inaccessible.
Returns:
the int value represented by the string associated with key in this preference node, or def if the associated value does not exist or cannot be interpreted as an int.
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key is null.
See Also:
putInt(String,int) sample code for java.util.prefs.Preferences.putInt(java.lang.String, int) definition code for java.util.prefs.Preferences.putInt(java.lang.String, int) , get(String,String) sample code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String) definition code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String)

putLong sample code for java.util.prefs.Preferences.putLong(java.lang.String, long) definition code for java.util.prefs.Preferences.putLong(java.lang.String, long)

public abstract void putLong(String sample code for java.lang.String definition code for java.lang.String  key,
                             long value)
Associates a string representing the specified long value with the specified key in this preference node. The associated string is the one that would be returned if the long value were passed to Long.toString(long) sample code for java.lang.Long.toString(long) definition code for java.lang.Long.toString(long) . This method is intended for use in conjunction with getLong(java.lang.String, long) sample code for java.util.prefs.Preferences.getLong(java.lang.String, long) definition code for java.util.prefs.Preferences.getLong(java.lang.String, long) .

Parameters:
key - key with which the string form of value is to be associated.
value - value whose string form is to be associated with key.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key is null.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if key.length() exceeds MAX_KEY_LENGTH.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
getLong(String,long) sample code for java.util.prefs.Preferences.getLong(java.lang.String, long) definition code for java.util.prefs.Preferences.getLong(java.lang.String, long)

getLong sample code for java.util.prefs.Preferences.getLong(java.lang.String, long) definition code for java.util.prefs.Preferences.getLong(java.lang.String, long)

public abstract long getLong(String sample code for java.lang.String definition code for java.lang.String  key,
                             long def)
Returns the long value represented by the string associated with the specified key in this preference node. The string is converted to a long as by Long.parseLong(String) sample code for java.lang.Long.parseLong(java.lang.String) definition code for java.lang.Long.parseLong(java.lang.String) . Returns the specified default if there is no value associated with the key, the backing store is inaccessible, or if Long.parseLong(String) would throw a NumberFormatException sample code for java.lang.NumberFormatException definition code for java.lang.NumberFormatException if the associated value were passed. This method is intended for use in conjunction with putLong(java.lang.String, long) sample code for java.util.prefs.Preferences.putLong(java.lang.String, long) definition code for java.util.prefs.Preferences.putLong(java.lang.String, long) .

If the implementation supports stored defaults and such a default exists, is accessible, and could be converted to a long with Long.parseLong, this long is returned in preference to the specified default.

Parameters:
key - key whose associated value is to be returned as a long.
def - the value to be returned in the event that this preference node has no value associated with key or the associated value cannot be interpreted as a long, or the backing store is inaccessible.
Returns:
the long value represented by the string associated with key in this preference node, or def if the associated value does not exist or cannot be interpreted as a long.
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key is null.
See Also:
putLong(String,long) sample code for java.util.prefs.Preferences.putLong(java.lang.String, long) definition code for java.util.prefs.Preferences.putLong(java.lang.String, long) , get(String,String) sample code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String) definition code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String)

putBoolean sample code for java.util.prefs.Preferences.putBoolean(java.lang.String, boolean) definition code for java.util.prefs.Preferences.putBoolean(java.lang.String, boolean)

public abstract void putBoolean(String sample code for java.lang.String definition code for java.lang.String  key,
                                boolean value)
Associates a string representing the specified boolean value with the specified key in this preference node. The associated string is "true" if the value is true, and "false" if it is false. This method is intended for use in conjunction with getBoolean(java.lang.String, boolean) sample code for java.util.prefs.Preferences.getBoolean(java.lang.String, boolean) definition code for java.util.prefs.Preferences.getBoolean(java.lang.String, boolean) .

Parameters:
key - key with which the string form of value is to be associated.
value - value whose string form is to be associated with key.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key is null.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if key.length() exceeds MAX_KEY_LENGTH.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
getBoolean(String,boolean) sample code for java.util.prefs.Preferences.getBoolean(java.lang.String, boolean) definition code for java.util.prefs.Preferences.getBoolean(java.lang.String, boolean) , get(String,String) sample code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String) definition code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String)

getBoolean sample code for java.util.prefs.Preferences.getBoolean(java.lang.String, boolean) definition code for java.util.prefs.Preferences.getBoolean(java.lang.String, boolean)

public abstract boolean getBoolean(String sample code for java.lang.String definition code for java.lang.String  key,
                                   boolean def)
Returns the boolean value represented by the string associated with the specified key in this preference node. Valid strings are "true", which represents true, and "false", which represents false. Case is ignored, so, for example, "TRUE" and "False" are also valid. This method is intended for use in conjunction with putBoolean(java.lang.String, boolean) sample code for java.util.prefs.Preferences.putBoolean(java.lang.String, boolean) definition code for java.util.prefs.Preferences.putBoolean(java.lang.String, boolean) .

Returns the specified default if there is no value associated with the key, the backing store is inaccessible, or if the associated value is something other than "true" or "false", ignoring case.

If the implementation supports stored defaults and such a default exists and is accessible, it is used in preference to the specified default, unless the stored default is something other than "true" or "false", ignoring case, in which case the specified default is used.

Parameters:
key - key whose associated value is to be returned as a boolean.
def - the value to be returned in the event that this preference node has no value associated with key or the associated value cannot be interpreted as a boolean, or the backing store is inaccessible.
Returns:
the boolean value represented by the string associated with key in this preference node, or def if the associated value does not exist or cannot be interpreted as a boolean.
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key is null.
See Also:
get(String,String) sample code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String) definition code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String) , putBoolean(String,boolean) sample code for java.util.prefs.Preferences.putBoolean(java.lang.String, boolean) definition code for java.util.prefs.Preferences.putBoolean(java.lang.String, boolean)

putFloat sample code for java.util.prefs.Preferences.putFloat(java.lang.String, float) definition code for java.util.prefs.Preferences.putFloat(java.lang.String, float)

public abstract void putFloat(String sample code for java.lang.String definition code for java.lang.String  key,
                              float value)
Associates a string representing the specified float value with the specified key in this preference node. The associated string is the one that would be returned if the float value were passed to Float.toString(float) sample code for java.lang.Float.toString(float) definition code for java.lang.Float.toString(float) . This method is intended for use in conjunction with getFloat(java.lang.String, float) sample code for java.util.prefs.Preferences.getFloat(java.lang.String, float) definition code for java.util.prefs.Preferences.getFloat(java.lang.String, float) .

Parameters:
key - key with which the string form of value is to be associated.
value - value whose string form is to be associated with key.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key is null.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if key.length() exceeds MAX_KEY_LENGTH.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
getFloat(String,float) sample code for java.util.prefs.Preferences.getFloat(java.lang.String, float) definition code for java.util.prefs.Preferences.getFloat(java.lang.String, float)

getFloat sample code for java.util.prefs.Preferences.getFloat(java.lang.String, float) definition code for java.util.prefs.Preferences.getFloat(java.lang.String, float)

public abstract float getFloat(String sample code for java.lang.String definition code for java.lang.String  key,
                               float def)
Returns the float value represented by the string associated with the specified key in this preference node. The string is converted to an integer as by Float.parseFloat(String) sample code for java.lang.Float.parseFloat(java.lang.String) definition code for java.lang.Float.parseFloat(java.lang.String) . Returns the specified default if there is no value associated with the key, the backing store is inaccessible, or if Float.parseFloat(String) would throw a NumberFormatException sample code for java.lang.NumberFormatException definition code for java.lang.NumberFormatException if the associated value were passed. This method is intended for use in conjunction with putFloat(java.lang.String, float) sample code for java.util.prefs.Preferences.putFloat(java.lang.String, float) definition code for java.util.prefs.Preferences.putFloat(java.lang.String, float) .

If the implementation supports stored defaults and such a default exists, is accessible, and could be converted to a float with Float.parseFloat, this float is returned in preference to the specified default.

Parameters:
key - key whose associated value is to be returned as a float.
def - the value to be returned in the event that this preference node has no value associated with key or the associated value cannot be interpreted as a float, or the backing store is inaccessible.
Returns:
the float value represented by the string associated with key in this preference node, or def if the associated value does not exist or cannot be interpreted as a float.
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key is null.
See Also:
putFloat(String,float) sample code for java.util.prefs.Preferences.putFloat(java.lang.String, float) definition code for java.util.prefs.Preferences.putFloat(java.lang.String, float) , get(String,String) sample code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String) definition code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String)

putDouble sample code for java.util.prefs.Preferences.putDouble(java.lang.String, double) definition code for java.util.prefs.Preferences.putDouble(java.lang.String, double)

public abstract void putDouble(String sample code for java.lang.String definition code for java.lang.String  key,
                               double value)
Associates a string representing the specified double value with the specified key in this preference node. The associated string is the one that would be returned if the double value were passed to Double.toString(double) sample code for java.lang.Double.toString(double) definition code for java.lang.Double.toString(double) . This method is intended for use in conjunction with getDouble(java.lang.String, double) sample code for java.util.prefs.Preferences.getDouble(java.lang.String, double) definition code for java.util.prefs.Preferences.getDouble(java.lang.String, double) .

Parameters:
key - key with which the string form of value is to be associated.
value - value whose string form is to be associated with key.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key is null.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if key.length() exceeds MAX_KEY_LENGTH.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
getDouble(String,double) sample code for java.util.prefs.Preferences.getDouble(java.lang.String, double) definition code for java.util.prefs.Preferences.getDouble(java.lang.String, double)

getDouble sample code for java.util.prefs.Preferences.getDouble(java.lang.String, double) definition code for java.util.prefs.Preferences.getDouble(java.lang.String, double)

public abstract double getDouble(String sample code for java.lang.String definition code for java.lang.String  key,
                                 double def)
Returns the double value represented by the string associated with the specified key in this preference node. The string is converted to an integer as by Double.parseDouble(String) sample code for java.lang.Double.parseDouble(java.lang.String) definition code for java.lang.Double.parseDouble(java.lang.String) . Returns the specified default if there is no value associated with the key, the backing store is inaccessible, or if Double.parseDouble(String) would throw a NumberFormatException sample code for java.lang.NumberFormatException definition code for java.lang.NumberFormatException if the associated value were passed. This method is intended for use in conjunction with putDouble(java.lang.String, double) sample code for java.util.prefs.Preferences.putDouble(java.lang.String, double) definition code for java.util.prefs.Preferences.putDouble(java.lang.String, double) .

If the implementation supports stored defaults and such a default exists, is accessible, and could be converted to a double with Double.parseDouble, this double is returned in preference to the specified default.

Parameters:
key - key whose associated value is to be returned as a double.
def - the value to be returned in the event that this preference node has no value associated with key or the associated value cannot be interpreted as a double, or the backing store is inaccessible.
Returns:
the double value represented by the string associated with key in this preference node, or def if the associated value does not exist or cannot be interpreted as a double.
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key is null.
See Also:
putDouble(String,double) sample code for java.util.prefs.Preferences.putDouble(java.lang.String, double) definition code for java.util.prefs.Preferences.putDouble(java.lang.String, double) , get(String,String) sample code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String) definition code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String)

putByteArray sample code for java.util.prefs.Preferences.putByteArray(java.lang.String, byte[]) definition code for java.util.prefs.Preferences.putByteArray(java.lang.String, byte[])

public abstract void putByteArray(String sample code for java.lang.String definition code for java.lang.String  key,
                                  byte[] value)
Associates a string representing the specified byte array with the specified key in this preference node. The associated string is the Base64 encoding of the byte array, as defined in RFC 2045, Section 6.8, with one minor change: the string will consist solely of characters from the Base64 Alphabet; it will not contain any newline characters. Note that the maximum length of the byte array is limited to three quarters of MAX_VALUE_LENGTH so that the length of the Base64 encoded String does not exceed MAX_VALUE_LENGTH. This method is intended for use in conjunction with getByteArray(java.lang.String, byte[]) sample code for java.util.prefs.Preferences.getByteArray(java.lang.String, byte[]) definition code for java.util.prefs.Preferences.getByteArray(java.lang.String, byte[]) .

Parameters:
key - key with which the string form of value is to be associated.
value - value whose string form is to be associated with key.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key or value is null.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if key.length() exceeds MAX_KEY_LENGTH or if value.length exceeds MAX_VALUE_LENGTH*3/4.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
getByteArray(String,byte[]) sample code for java.util.prefs.Preferences.getByteArray(java.lang.String, byte[]) definition code for java.util.prefs.Preferences.getByteArray(java.lang.String, byte[]) , get(String,String) sample code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String) definition code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String)

getByteArray sample code for java.util.prefs.Preferences.getByteArray(java.lang.String, byte[]) definition code for java.util.prefs.Preferences.getByteArray(java.lang.String, byte[])

public abstract byte[] getByteArray(String sample code for java.lang.String definition code for java.lang.String  key,
                                    byte[] def)
Returns the byte array value represented by the string associated with the specified key in this preference node. Valid strings are Base64 encoded binary data, as defined in RFC 2045, Section 6.8, with one minor change: the string must consist solely of characters from the Base64 Alphabet; no newline characters or extraneous characters are permitted. This method is intended for use in conjunction with putByteArray(java.lang.String, byte[]) sample code for java.util.prefs.Preferences.putByteArray(java.lang.String, byte[]) definition code for java.util.prefs.Preferences.putByteArray(java.lang.String, byte[]) .

Returns the specified default if there is no value associated with the key, the backing store is inaccessible, or if the associated value is not a valid Base64 encoded byte array (as defined above).

If the implementation supports stored defaults and such a default exists and is accessible, it is used in preference to the specified default, unless the stored default is not a valid Base64 encoded byte array (as defined above), in which case the specified default is used.

Parameters:
key - key whose associated value is to be returned as a byte array.
def - the value to be returned in the event that this preference node has no value associated with key or the associated value cannot be interpreted as a byte array, or the backing store is inaccessible.
Returns:
the byte array value represented by the string associated with key in this preference node, or def if the associated value does not exist or cannot be interpreted as a byte array.
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if key is null. (A null value for def is permitted.)
See Also:
get(String,String) sample code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String) definition code for java.util.prefs.Preferences.get(java.lang.String, java.lang.String) , putByteArray(String,byte[]) sample code for java.util.prefs.Preferences.putByteArray(java.lang.String, byte[]) definition code for java.util.prefs.Preferences.putByteArray(java.lang.String, byte[])

keys sample code for java.util.prefs.Preferences.keys() definition code for java.util.prefs.Preferences.keys()

public abstract String sample code for java.lang.String definition code for java.lang.String [] keys()
                       throws BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException 
Returns all of the keys that have an associated value in this preference node. (The returned array will be of size zero if this node has no preferences.)

If the implementation supports stored defaults and there are any such defaults at this node that have not been overridden, by explicit preferences, the defaults are returned in the array in addition to any explicit preferences.

Returns:
an array of the keys that have an associated value in this preference node.
Throws:
BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException - if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.

childrenNames sample code for java.util.prefs.Preferences.childrenNames() definition code for java.util.prefs.Preferences.childrenNames()

public abstract String sample code for java.lang.String definition code for java.lang.String [] childrenNames()
                                throws BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException 
Returns the names of the children of this preference node, relative to this node. (The returned array will be of size zero if this node has no children.)

Returns:
the names of the children of this preference node.
Throws:
BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException - if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.

parent sample code for java.util.prefs.Preferences.parent() definition code for java.util.prefs.Preferences.parent()

public abstract Preferences sample code for java.util.prefs.Preferences definition code for java.util.prefs.Preferences  parent()
Returns the parent of this preference node, or null if this is the root.

Returns:
the parent of this preference node.
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.

node sample code for java.util.prefs.Preferences.node(java.lang.String) definition code for java.util.prefs.Preferences.node(java.lang.String)

public abstract Preferences sample code for java.util.prefs.Preferences definition code for java.util.prefs.Preferences  node(String sample code for java.lang.String definition code for java.lang.String  pathName)
Returns the named preference node in the same tree as this node, creating it and any of its ancestors if they do not already exist. Accepts a relative or absolute path name. Relative path names (which do not begin with the slash character ('/')) are interpreted relative to this preference node.

If the returned node did not exist prior to this call, this node and any ancestors that were created by this call are not guaranteed to become permanent until the flush method is called on the returned node (or one of its ancestors or descendants).

Parameters:
pathName - the path name of the preference node to return.
Returns:
the specified preference node.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the path name is invalid (i.e., it contains multiple consecutive slash characters, or ends with a slash character and is more than one character long).
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if path name is null.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
flush() sample code for java.util.prefs.Preferences.flush() definition code for java.util.prefs.Preferences.flush()

nodeExists sample code for java.util.prefs.Preferences.nodeExists(java.lang.String) definition code for java.util.prefs.Preferences.nodeExists(java.lang.String)

public abstract boolean nodeExists(String sample code for java.lang.String definition code for java.lang.String  pathName)
                            throws BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException 
Returns true if the named preference node exists in the same tree as this node. Relative path names (which do not begin with the slash character ('/')) are interpreted relative to this preference node.

If this node (or an ancestor) has already been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method, it is legal to invoke this method, but only with the path name ""; the invocation will return false. Thus, the idiom p.nodeExists("") may be used to test whether p has been removed.

Parameters:
pathName - the path name of the node whose existence is to be checked.
Returns:
true if the specified node exists.
Throws:
BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException - if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the path name is invalid (i.e., it contains multiple consecutive slash characters, or ends with a slash character and is more than one character long).
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if path name is null. s * @throws IllegalStateException if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method and pathName is not the empty string ("").

removeNode sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode()

public abstract void removeNode()
                         throws BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException 
Removes this preference node and all of its descendants, invalidating any preferences contained in the removed nodes. Once a node has been removed, attempting any method other than name() sample code for java.util.prefs.Preferences.name() definition code for java.util.prefs.Preferences.name() , absolutePath() sample code for java.util.prefs.Preferences.absolutePath() definition code for java.util.prefs.Preferences.absolutePath() , isUserNode() sample code for java.util.prefs.Preferences.isUserNode() definition code for java.util.prefs.Preferences.isUserNode() , flush() sample code for java.util.prefs.Preferences.flush() definition code for java.util.prefs.Preferences.flush() or nodeExists("") sample code for java.util.prefs.Preferences.node(java.lang.String) definition code for java.util.prefs.Preferences.node(java.lang.String) on the corresponding Preferences instance will fail with an IllegalStateException. (The methods defined on Object sample code for java.lang.Object definition code for java.lang.Object can still be invoked on a node after it has been removed; they will not throw IllegalStateException.)

The removal is not guaranteed to be persistent until the flush method is called on this node (or an ancestor).

If this implementation supports stored defaults, removing a node exposes any stored defaults at or below this node. Thus, a subsequent call to nodeExists on this node's path name may return true, and a subsequent call to node on this path name may return a (different) Preferences instance representing a non-empty collection of preferences and/or children.

Throws:
BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException - if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has already been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
UnsupportedOperationException sample code for java.lang.UnsupportedOperationException definition code for java.lang.UnsupportedOperationException - if this method is invoked on the root node.
See Also:
flush() sample code for java.util.prefs.Preferences.flush() definition code for java.util.prefs.Preferences.flush()

name sample code for java.util.prefs.Preferences.name() definition code for java.util.prefs.Preferences.name()

public abstract String sample code for java.lang.String definition code for java.lang.String  name()
Returns this preference node's name, relative to its parent.

Returns:
this preference node's name, relative to its parent.

absolutePath sample code for java.util.prefs.Preferences.absolutePath() definition code for java.util.prefs.Preferences.absolutePath()

public abstract String sample code for java.lang.String definition code for java.lang.String  absolutePath()
Returns this preference node's absolute path name.

Returns:
this preference node's absolute path name.

isUserNode sample code for java.util.prefs.Preferences.isUserNode() definition code for java.util.prefs.Preferences.isUserNode()

public abstract boolean isUserNode()
Returns true if this preference node is in the user preference tree, false if it's in the system preference tree.

Returns:
true if this preference node is in the user preference tree, false if it's in the system preference tree.

toString sample code for java.util.prefs.Preferences.toString() definition code for java.util.prefs.Preferences.toString()

public abstract String sample code for java.lang.String definition code for java.lang.String  toString()
Returns a string representation of this preferences node, as if computed by the expression:(this.isUserNode() ? "User" : "System") + " Preference Node: " + this.absolutePath().

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a string representation of the object.

flush sample code for java.util.prefs.Preferences.flush() definition code for java.util.prefs.Preferences.flush()

public abstract void flush()
                    throws BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException 
Forces any changes in the contents of this preference node and its descendants to the persistent store. Once this method returns successfully, it is safe to assume that all changes made in the subtree rooted at this node prior to the method invocation have become permanent.

Implementations are free to flush changes into the persistent store at any time. They do not need to wait for this method to be called.

When a flush occurs on a newly created node, it is made persistent, as are any ancestors (and descendants) that have yet to be made persistent. Note however that any preference value changes in ancestors are not guaranteed to be made persistent.

If this method is invoked on a node that has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method, flushSpi() is invoked on this node, but not on others.

Throws:
BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException - if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.
See Also:
sync() sample code for java.util.prefs.Preferences.sync() definition code for java.util.prefs.Preferences.sync()

sync sample code for java.util.prefs.Preferences.sync() definition code for java.util.prefs.Preferences.sync()

public abstract void sync()
                   throws BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException 
Ensures that future reads from this preference node and its descendants reflect any changes that were committed to the persistent store (from any VM) prior to the sync invocation. As a side-effect, forces any changes in the contents of this preference node and its descendants to the persistent store, as if the flush method had been invoked on this node.

Throws:
BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException - if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
flush() sample code for java.util.prefs.Preferences.flush() definition code for java.util.prefs.Preferences.flush()

addPreferenceChangeListener sample code for java.util.prefs.Preferences.addPreferenceChangeListener(java.util.prefs.PreferenceChangeListener) definition code for java.util.prefs.Preferences.addPreferenceChangeListener(java.util.prefs.PreferenceChangeListener)

public abstract void addPreferenceChangeListener(PreferenceChangeListener sample code for java.util.prefs.PreferenceChangeListener definition code for java.util.prefs.PreferenceChangeListener  pcl)
Registers the specified listener to receive preference change events for this preference node. A preference change event is generated when a preference is added to this node, removed from this node, or when the value associated with a preference is changed. (Preference change events are not generated by the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method, which generates a node change event. Preference change events are generated by the clear method.)

Events are only guaranteed for changes made within the same JVM as the registered listener, though some implementations may generate events for changes made outside this JVM. Events may be generated before the changes have been made persistent. Events are not generated when preferences are modified in descendants of this node; a caller desiring such events must register with each descendant.

Parameters:
pcl - The preference change listener to add.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if pcl is null.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
removePreferenceChangeListener(PreferenceChangeListener) sample code for java.util.prefs.Preferences.removePreferenceChangeListener(java.util.prefs.PreferenceChangeListener) definition code for java.util.prefs.Preferences.removePreferenceChangeListener(java.util.prefs.PreferenceChangeListener) , addNodeChangeListener(NodeChangeListener) sample code for java.util.prefs.Preferences.addNodeChangeListener(java.util.prefs.NodeChangeListener) definition code for java.util.prefs.Preferences.addNodeChangeListener(java.util.prefs.NodeChangeListener)

removePreferenceChangeListener sample code for java.util.prefs.Preferences.removePreferenceChangeListener(java.util.prefs.PreferenceChangeListener) definition code for java.util.prefs.Preferences.removePreferenceChangeListener(java.util.prefs.PreferenceChangeListener)

public abstract void removePreferenceChangeListener(PreferenceChangeListener sample code for java.util.prefs.PreferenceChangeListener definition code for java.util.prefs.PreferenceChangeListener  pcl)
Removes the specified preference change listener, so it no longer receives preference change events.

Parameters:
pcl - The preference change listener to remove.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if pcl was not a registered preference change listener on this node.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
addPreferenceChangeListener(PreferenceChangeListener) sample code for java.util.prefs.Preferences.addPreferenceChangeListener(java.util.prefs.PreferenceChangeListener) definition code for java.util.prefs.Preferences.addPreferenceChangeListener(java.util.prefs.PreferenceChangeListener)

addNodeChangeListener sample code for java.util.prefs.Preferences.addNodeChangeListener(java.util.prefs.NodeChangeListener) definition code for java.util.prefs.Preferences.addNodeChangeListener(java.util.prefs.NodeChangeListener)

public abstract void addNodeChangeListener(NodeChangeListener sample code for java.util.prefs.NodeChangeListener definition code for java.util.prefs.NodeChangeListener  ncl)
Registers the specified listener to receive node change events for this node. A node change event is generated when a child node is added to or removed from this node. (A single removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() invocation results in multiple node change events, one for every node in the subtree rooted at the removed node.)

Events are only guaranteed for changes made within the same JVM as the registered listener, though some implementations may generate events for changes made outside this JVM. Events may be generated before the changes have become permanent. Events are not generated when indirect descendants of this node are added or removed; a caller desiring such events must register with each descendant.

Few guarantees can be made regarding node creation. Because nodes are created implicitly upon access, it may not be feasible for an implementation to determine whether a child node existed in the backing store prior to access (for example, because the backing store is unreachable or cached information is out of date). Under these circumstances, implementations are neither required to generate node change events nor prohibited from doing so.

Parameters:
ncl - The NodeChangeListener to add.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if ncl is null.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
removeNodeChangeListener(NodeChangeListener) sample code for java.util.prefs.Preferences.removeNodeChangeListener(java.util.prefs.NodeChangeListener) definition code for java.util.prefs.Preferences.removeNodeChangeListener(java.util.prefs.NodeChangeListener) , addPreferenceChangeListener(PreferenceChangeListener) sample code for java.util.prefs.Preferences.addPreferenceChangeListener(java.util.prefs.PreferenceChangeListener) definition code for java.util.prefs.Preferences.addPreferenceChangeListener(java.util.prefs.PreferenceChangeListener)

removeNodeChangeListener sample code for java.util.prefs.Preferences.removeNodeChangeListener(java.util.prefs.NodeChangeListener) definition code for java.util.prefs.Preferences.removeNodeChangeListener(java.util.prefs.NodeChangeListener)

public abstract void removeNodeChangeListener(NodeChangeListener sample code for java.util.prefs.NodeChangeListener definition code for java.util.prefs.NodeChangeListener  ncl)
Removes the specified NodeChangeListener, so it no longer receives change events.

Parameters:
ncl - The NodeChangeListener to remove.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if ncl was not a registered NodeChangeListener on this node.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
addNodeChangeListener(NodeChangeListener) sample code for java.util.prefs.Preferences.addNodeChangeListener(java.util.prefs.NodeChangeListener) definition code for java.util.prefs.Preferences.addNodeChangeListener(java.util.prefs.NodeChangeListener)

exportNode sample code for java.util.prefs.Preferences.exportNode(java.io.OutputStream) definition code for java.util.prefs.Preferences.exportNode(java.io.OutputStream)

public abstract void exportNode(OutputStream sample code for java.io.OutputStream definition code for java.io.OutputStream  os)
                         throws IOException sample code for java.io.IOException definition code for java.io.IOException ,
                                BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException 
Emits on the specified output stream an XML document representing all of the preferences contained in this node (but not its descendants). This XML document is, in effect, an offline backup of the node.

The XML document will have the following DOCTYPE declaration:

 <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
 
The UTF-8 character encoding will be used.

This method is an exception to the general rule that the results of concurrently executing multiple methods in this class yields results equivalent to some serial execution. If the preferences at this node are modified concurrently with an invocation of this method, the exported preferences comprise a "fuzzy snapshot" of the preferences contained in the node; some of the concurrent modifications may be reflected in the exported data while others may not.

Parameters:
os - the output stream on which to emit the XML document.
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - if writing to the specified output stream results in an IOException.
BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException - if preference data cannot be read from backing store.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
importPreferences(InputStream) sample code for java.util.prefs.Preferences.importPreferences(java.io.InputStream) definition code for java.util.prefs.Preferences.importPreferences(java.io.InputStream)

exportSubtree sample code for java.util.prefs.Preferences.exportSubtree(java.io.OutputStream) definition code for java.util.prefs.Preferences.exportSubtree(java.io.OutputStream)

public abstract void exportSubtree(OutputStream sample code for java.io.OutputStream definition code for java.io.OutputStream  os)
                            throws IOException sample code for java.io.IOException definition code for java.io.IOException ,
                                   BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException 
Emits an XML document representing all of the preferences contained in this node and all of its descendants. This XML document is, in effect, an offline backup of the subtree rooted at the node.

The XML document will have the following DOCTYPE declaration:

 <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
 
The UTF-8 character encoding will be used.

This method is an exception to the general rule that the results of concurrently executing multiple methods in this class yields results equivalent to some serial execution. If the preferences or nodes in the subtree rooted at this node are modified concurrently with an invocation of this method, the exported preferences comprise a "fuzzy snapshot" of the subtree; some of the concurrent modifications may be reflected in the exported data while others may not.

Parameters:
os - the output stream on which to emit the XML document.
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - if writing to the specified output stream results in an IOException.
BackingStoreException sample code for java.util.prefs.BackingStoreException definition code for java.util.prefs.BackingStoreException - if preference data cannot be read from backing store.
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this node (or an ancestor) has been removed with the removeNode() sample code for java.util.prefs.Preferences.removeNode() definition code for java.util.prefs.Preferences.removeNode() method.
See Also:
importPreferences(InputStream) sample code for java.util.prefs.Preferences.importPreferences(java.io.InputStream) definition code for java.util.prefs.Preferences.importPreferences(java.io.InputStream) , exportNode(OutputStream) sample code for java.util.prefs.Preferences.exportNode(java.io.OutputStream) definition code for java.util.prefs.Preferences.exportNode(java.io.OutputStream)

importPreferences sample code for java.util.prefs.Preferences.importPreferences(java.io.InputStream) definition code for java.util.prefs.Preferences.importPreferences(java.io.InputStream)

public static void importPreferences(InputStream sample code for java.io.InputStream definition code for java.io.InputStream  is)
                              throws IOException sample code for java.io.IOException definition code for java.io.IOException ,
                                     InvalidPreferencesFormatException sample code for java.util.prefs.InvalidPreferencesFormatException definition code for java.util.prefs.InvalidPreferencesFormatException 
Imports all of the preferences represented by the XML document on the specified input stream. The document may represent user preferences or system preferences. If it represents user preferences, the preferences will be imported into the calling user's preference tree (even if they originally came from a different user's preference tree). If any of the preferences described by the document inhabit preference nodes that do not exist, the nodes will be created.

The XML document must have the following DOCTYPE declaration:

 <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
 
(This method is designed for use in conjunction with exportNode(OutputStream) sample code for java.util.prefs.Preferences.exportNode(java.io.OutputStream) definition code for java.util.prefs.Preferences.exportNode(java.io.OutputStream) and exportSubtree(OutputStream) sample code for java.util.prefs.Preferences.exportSubtree(java.io.OutputStream) definition code for java.util.prefs.Preferences.exportSubtree(java.io.OutputStream) .

This method is an exception to the general rule that the results of concurrently executing multiple methods in this class yields results equivalent to some serial execution. The method behaves as if implemented on top of the other public methods in this class, notably node(String) sample code for java.util.prefs.Preferences.node(java.lang.String) definition code for java.util.prefs.Preferences.node(java.lang.String) and put(String, String) sample code for java.util.prefs.Preferences.put(java.lang.String, java.lang.String) definition code for java.util.prefs.Preferences.put(java.lang.String, java.lang.String) .

Parameters:
is - the input stream from which to read the XML document.
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - if reading from the specified output stream results in an IOException.
InvalidPreferencesFormatException sample code for java.util.prefs.InvalidPreferencesFormatException definition code for java.util.prefs.InvalidPreferencesFormatException - Data on input stream does not constitute a valid XML document with the mandated document type.
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - If a security manager is present and it denies RuntimePermission("preferences").
See Also:
RuntimePermission sample code for java.lang.RuntimePermission definition code for java.lang.RuntimePermission