Example usage for java.util.prefs Preferences exportNode

List of usage examples for java.util.prefs Preferences exportNode

Introduction

In this page you can find the example usage for java.util.prefs Preferences exportNode.

Prototype

public abstract void exportNode(OutputStream os) throws IOException, BackingStoreException;

Source Link

Document

Emits on the specified output stream an XML document representing all of the preferences contained in this node (but not its descendants).

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Preferences prefs = Preferences.userNodeForPackage(String.class);

    // Save some values
    prefs.put("myString", "a string"); // String
    prefs.putBoolean("myBoolean", true); // boolean
    prefs.putInt("myInt", 123); // int
    prefs.putLong("myLong", 123L); // long
    prefs.putFloat("myFloat", 12.3F); // float
    prefs.putDouble("myDouble", 12.3); // double
    byte[] bytes = new byte[10];
    prefs.putByteArray("myByteArray", bytes); // byte[]

    // Export the node to a file
    prefs.exportNode(new FileOutputStream("output.xml"));

}