Reputation: 313
In my eclipse project 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
Upvotes: 0
Views: 1389
Reputation: 597106
java.util.Properties.store(..)
to savejava.util.Properties.load(..)
to loadUpvotes: 2
Reputation: 46137
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) {
}
Upvotes: 0