Source Code : Saving Data with the Preferences API
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Saving Data with the Preferences API

import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
public class PlanetPrefs {
public static void main(String args[]) {
String names[] = { "Mercury", "Venus", "Earth", "Mars", "Jupiter",
"Saturn", "Uranus", "Neptune", "Pluto" };
int moons[] = { 0, 0, 1, 2, 16, 18, 21, 8, 1 };
Preferences prefs = Preferences.userRoot()
.node("/MasteringJava/Chap17");
for (int i = 0, n = names.length; i < n; i++) {
prefs.putInt(names[i], moons[i]);
}
try {
String keys[] = prefs.keys();
for (int i = 0, n = keys.length; i < n; i++) {
System.out.println(keys[i] + ": " + prefs.getInt(keys[i], 0));
}
} catch (BackingStoreException e) {
System.err.println("Unable to read backing store: " + e);
}
}
}
Thank with us