Importing preferences
suggest changePreferences nodes can be imported from an XML document produced by the export methods. The document records whether it came from the user tree or the system tree. Preferences.importPreferences selects that tree. A user-tree document is imported into the calling user's tree, which is not necessarily the account that originally exported it. The method does not close the stream.
try (InputStream is = ...) {
// This is a static call on the Preferences class
Preferences.importPreferences(is);
} catch (IOException ioe) {
// Exception whilst reading data from the InputStream
ioe.printStackTrace();
} catch (InvalidPreferencesFormatException ipfe) {
// Exception whilst parsing the XML document tree
ipfe.printStackTrace();
}
InputStream is = null;
try {
is = ...;
// This is a static call on the Preferences class
Preferences.importPreferences(is);
} catch (IOException ioe) {
// Exception whilst reading data from the InputStream
ioe.printStackTrace();
} catch (InvalidPreferencesFormatException ipfe) {
// Exception whilst parsing the XML document tree
ipfe.printStackTrace();
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ignored) {}
}
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents