Java Reference
In-Depth Information
ginating WatchService is closed. If the eventKey returns false, you should break
from the watch loop.
8-12. Reading Property Files
Problem
You want to establish some configurational settings for your application, and you want
to have the ability to modify the settings manually or programmatically.
Solution
Create a properties file to store the application configurations. Using the Proper-
ties object, load properties stored within the properties file for application process-
ing. Properties can also be updated and modified within the properties file. The fol-
lowing example demonstrates how to read a properties file named proper-
ties.conf , load the values for application use, and finally set a property and write it
to the file.
File file = new File("properties.conf");
try {
if (!file.exists()) file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
Properties properties = new Properties();
try {
properties.load(new
FileInputStream("properties.conf"));
} catch (IOException e) {
e.printStackTrace();
}
boolean shouldWakeUp = false;
int startCounter = 100;
Search WWH ::




Custom Search