A Java Preferences for larger amounts of data
₹100-110 INR / Stunde
After two days of hacking around with the Java Preferences,
I have come to the conclusion that Preferences were
never meant to store large amounts of data.
It seems to me that this is an important sub-problem.
One of the people who has addressed the problem is
David Croft. His code, which uses properties, is still unable to
serialize large amounts of data, for reasons I cannot fathom.
[url removed, login to view]
shows his file example.
The simplest example I can use to break his code appears below.
We are interested in a java program that enables
the storing of larger amounts of data in file preferences (perhaps [url removed, login to view] or so).
Thanks!
- D
public static void main(String[] args) throws BackingStoreException {
Preferences p = getPreferences([url removed, login to view]);
for (String s : [url removed, login to view]()) {
[url removed, login to view]("p[" + s + "]=" + [url removed, login to view](s, null));
}
StringBuffer sb = new StringBuffer();
for (int i=0; i < 1<<11; i++){
[url removed, login to view](" "+i);
}
[url removed, login to view]("hi", true);
[url removed, login to view]("Number", [url removed, login to view]([url removed, login to view]()));
[url removed, login to view]("large string",[url removed, login to view]());
}
public static Preferences getPreferences(Object c) {
[url removed, login to view]("[url removed, login to view]", [url removed, login to view]());
File preferenceDir = [url removed, login to view]();
[url removed, login to view]("preferenceDir:"+preferenceDir);
File preferenceFile = new File(preferenceDir,"[url removed, login to view]");
[url removed, login to view](SYSTEM_PROPERTY_FILE, [url removed, login to view]());
[url removed, login to view]("storing preferences in:"+preferenceFile);
return [url removed, login to view]([url removed, login to view]());
}
Projekt-ID: #5268591