This section demonstrates you the use of class PreferenceStore.
SWT provides the class PreferenceStore to persist the non-default values to the files or streams and to load the default values from the file or streams.
The method setDefault(String name, String value) sets the default value for the string-valued preference with the given name. The method load() of this class loads the preference store from the given file. The method preferenceStore.list(System.out) prints the contents of the preference store to the console.
Create a file "hello.properties" and write the values for the Name, Department and Address in the file:
Here is the code of PreferenceStoreExample.java
Output will be displayed as:
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: October 24, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles