Java examples for Native OS:Preference
Exporting the Preferences in a Preference Node
import java.io.FileOutputStream; import java.io.IOException; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; public class Main { public void m() { Preferences prefs = Preferences.userNodeForPackage(String.class); 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[] try {//from ww w. j a va 2 s. c o m // Export the node to a file prefs.exportNode(new FileOutputStream("output.xml")); } catch (IOException e) { } catch (BackingStoreException e) { } } }