class Pref1
{
public static void main(String ar[])
{
Preferences prefs = Preferences.userRoot( ).node("java/notes");
prefs.put("author", "Hemraj");
prefs.putInt("edition", 1);
String author = prefs.get("author", "unknown");
int edition = prefs.getInt("edition", -1);
}
}
=====================================================
import java.util.prefs.*;
class Pref1
{
public static void main(String ar[])
{
Preferences prefs = Preferences.userRoot( ).node("java/notes");
String author = prefs.get("author", "unknown");
int edition = prefs.getInt("edition", -1);
System.out.println(author+" , "+edition);
}
}
In this program the program Pref2 stores the value Hemraj and 1 with the corresponding keys author and edition. Next program get these value using the same keys by which stored prior.
No comments:
Post a Comment