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:
| Name=Khushi Department=Computer Science Address=Rohini |
Here is the code of PreferenceStoreExample.java
import java.io.IOException;
|
Output will be displayed as:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Use of PreferenceStore class
Post your Comment