Hi All,I want to do some coding for my requirement using
Java Preference API.I read some of the articals and done some samples.When i export the preferences to the xml file it is exporting and showing values in xml.My problem is when i delete the preferences in the xml manually then also when i compile the code it is again getting the deleted values in the xml.My doubt is where the preferences are storing,whether it is storing in xml only or by defalut any other storage........And anyone can give me some Java Preference API urls where i can find some information...thanq...
This is my code
------------------
import java.util.*;
import java.util.prefs.*;
import java.io.*;
public class PreferenceExample {
public void printInformation(Preferences p) throws BackingStoreException{
String s=p.get("url", "");
System.out.println(s+":This is the url value");
}
public void setSomeProperties(Preferences p) throws BackingStoreException {
p.put("url","ldap://indc6:389");
p.put("username","ravikum@in.nds.com");
p.put("password", "Reddy@2504");
}
public void exportToFile(Preferences p, String fileName)
throws BackingStoreException {
try {
FileOutputStream fos = new FileOutputStream(fileName);
p.exportSubtree(fos);
fos.close();
} catch (IOException ioe) {
System.out.println("IOException in exportToFile\n" + ioe);
ioe.printStackTrace();
}
}
public static void main(String args[]) {
PreferenceExample pe = new PreferenceExample();
Preferences prefsRoot = Preferences.userRoot();
Preferences myPrefs = prefsRoot.node("PreferenceExample");
try {
pe.setSomeProperties(myPrefs);
pe.printInformation(myPrefs);
pe.exportToFile(myPrefs, "pref.xml");
} catch (BackingStoreException bse) {
System.out.println("Problem with accessing the backing store\n"+ bse);
bse.printStackTrace();
}
}
}