List of usage examples for java.util.prefs Preferences parent
public abstract Preferences parent();
From source file:Main.java
public static void main(String[] argv) throws Exception { Preferences prefs = Preferences.userNodeForPackage(java.lang.String.class); Preferences node = prefs.parent(); // /java node = node.parent(); // null String[] names = null;/* w ww . j a va2s . c om*/ names = prefs.childrenNames(); for (int i = 0; i < names.length; i++) { node = prefs.node(names[i]); } }
From source file:PreferenceExample.java
public static void main(String args[]) throws Exception { Preferences prefsRoot = Preferences.userRoot(); Preferences myPrefs = prefsRoot.node("PreferenceExample"); myPrefs.put("A", "a"); myPrefs.put("B", "b"); myPrefs.put("C", "c"); System.out.println("Node's name: " + myPrefs.name()); System.out.println("Node's parent: " + myPrefs.parent()); System.out.println("NODE: " + myPrefs); }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Get the system root Preferences prefs = Preferences.systemRoot(); // Get the user root prefs = Preferences.userRoot(); // The name of a root is "" String name = prefs.name();// w ww. j a v a 2s .co m // The parent of a root is null Preferences parent = prefs.parent(); // The absolute path of a root is "/" String path = prefs.absolutePath(); }
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 // Save some values in the parent node prefs = prefs.parent(); prefs.putFloat("myFloat", 12.3F); // float prefs.putDouble("myDouble", 12.3); // double byte[] bytes = new byte[10]; prefs.putByteArray("myByteArray", bytes); // byte[] prefs.exportSubtree(new FileOutputStream("output.xml")); }
From source file:PreferenceExample.java
public void printInformation(Preferences p) throws BackingStoreException { System.out.println("Node's absolute path: " + p.absolutePath()); System.out.print("Node's children: "); for (String s : p.childrenNames()) { System.out.print(s + " "); }// ww w . j av a2s . c o m System.out.println(""); System.out.print("Node's keys: "); for (String s : p.keys()) { System.out.print(s + " "); } System.out.println(""); System.out.println("Node's name: " + p.name()); System.out.println("Node's parent: " + p.parent()); System.out.println("NODE: " + p); System.out.println("userNodeForPackage: " + Preferences.userNodeForPackage(PreferenceExample.class)); System.out.println("All information in node"); for (String s : p.keys()) { System.out.println(" " + s + " = " + p.get(s, "")); } }