List of usage examples for java.util.prefs Preferences node
public abstract Preferences node(String pathName);
From source file:Main.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 absolute path: " + myPrefs.absolutePath()); }
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("userNodeForPackage: " + Preferences.userNodeForPackage(PreferenceExample.class)); }
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: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"); for (String s : myPrefs.keys()) { System.out.println("" + s + "= " + myPrefs.get(s, "")); }/*from ww w. ja va 2 s .c om*/ }
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.print("Node's keys: "); for (String s : myPrefs.keys()) { System.out.print(s + ""); }//from w w w. ja v a 2s .c o m }
From source file:Main.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"); FileOutputStream fos = new FileOutputStream("prefs.xml"); myPrefs.exportSubtree(fos);/*from www .j a va 2 s . c o m*/ fos.close(); }
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.print("Node's children: "); for (String s : myPrefs.childrenNames()) { System.out.print(s + ""); }/* w ww.j a va 2s . c o m*/ }
From source file:PreferenceExample.java
public static void main(String args[]) { PreferenceExample pe = new PreferenceExample(); Preferences prefsRoot = Preferences.userRoot(); Preferences myPrefs = prefsRoot.node("PreferenceExample"); try {//from w w w .j a v a2 s.c om pe.setSomeProperties(myPrefs); pe.printInformation(myPrefs); pe.exportToFile(myPrefs, "prefs.xml"); } catch (BackingStoreException bse) { System.out.println("Problem with accessing the backing store\n" + bse); bse.printStackTrace(); } }
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;//from w w w. j a v a 2s. c o m names = prefs.childrenNames(); for (int i = 0; i < names.length; i++) { node = prefs.node(names[i]); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { // System preference nodes // Use a Class Preferences prefs = Preferences.systemNodeForPackage(java.lang.String.class); // Use an absolute path prefs = Preferences.systemRoot().node("/java/lang/String"); // Use a relative path prefs = Preferences.systemRoot().node("/javax/swing"); prefs = prefs.node("text/html"); // User preference nodes // Use a class prefs = Preferences.userNodeForPackage(Main.class); // Use an absolute path prefs = Preferences.userRoot().node("/com/mycompany"); // Use a relative path prefs = Preferences.userRoot().node("/javax/swing"); prefs = prefs.node("text/html"); }