![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e418. Importing PreferencesPreferences can be exported usingPreferences.exportNode() (see
e419 Exporting the Preferences in a Preference Node) and Preferences.exportSubtree()
(see e420 Exporting the Preferences in a Subtree of Preference Nodes). This exported data can
be imported using Preferences.importPreferences() .
Each preference in exported data contains the path of the node that held the preference. When the exported preference is later imported, it is added to the node with the same path. This example demonstrates how to import a file of exported preference data. // Create an input stream on a file InputStream is = null; try { is = new BufferedInputStream(new FileInputStream("output.xml")); } catch (FileNotFoundException e) { } // Import preference data try { Preferences.importPreferences(is); } catch (InvalidPreferencesFormatException e) { } catch (IOException e) { }
e420. Exporting the Preferences in a Subtree of Preference Nodes
© 2002 Addison-Wesley. |