Importing preferences

suggest change

Preferences 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) {}
    }
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents