java: how to add values to properties file and access them in program
In my eclipse pr开发者_如何学Coject i have ip address string variable in many java class files, few jsps and also in context.xml file. I want to create a kind .properties file and declare this ip address as key value pair and access from all the classes from this particular file.How do i achieve this?
Regards TT
java.util.Properties.store(..)
to savejava.util.Properties.load(..)
to load
Use something like this:
// Read properties file.
Properties properties = new Properties();
try {
properties.load(new FileInputStream("filename.properties"));
String value = properties.getProperty("propertyKey");
} catch (IOException e) {
}
精彩评论