How to Get Children Names from Preferences

From Java Example Source Code

Jump to: navigation, search

Contents

[edit] Overview - How to Get Children Names from Preferences

This Java example program shows how to get children names from Preferences.

[edit] Java Source Code

  • Package: example.preferenceproperties
  • File: PreferenceExample1.java
package example.preferenceproperties1;
 
import java.util.prefs.Preferences;
 
public class PreferenceExample1 {
    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 + "");
	}
 
    }
}

[edit] What Result You Can Get

Run the program, you will get:

Node's children:

[edit] Required External Libraries and/or Files for this Java Example

Need nothing.


[edit] How to Run this Java Example Program

We recommend running this Java example program with Eclipse.

For assistance in working with Eclipse, please see How to Run Java Program with Eclipse.

It's fairly easy.



[edit] Question & Answer

Any question?

Click edit and post your question or answer here.


Personal tools