Java examples for Native OS:Preference
Exporting the Preferences in a Subtree of Preference Nodes
import java.io.FileOutputStream; import java.io.IOException; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; public class Main { public void m() throws Exception { // Retrieve the user preference node for the package java.lang 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 // Save some values in the parent node prefs = prefs.parent();/*from w w w. j a va2 s. c o m*/ prefs.putFloat("myFloat", 12.3F); // float prefs.putDouble("myDouble", 12.3); // double byte[] bytes = new byte[10]; prefs.putByteArray("myByteArray", bytes); // byte[] try { prefs.exportSubtree(new FileOutputStream("output.xml")); } catch (IOException e) { } catch (BackingStoreException e) { } } }