dcsimg
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Java
Expertise: Intermediate
Jan 21, 2009

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


How to Use Properties Files in Java

In Java, you can easily create and use a properties file containing name/value pairs. First, make a .properties file—name it Properties.properties. Place key/value pairs such as name = java in the file where "name" is the key and "java" is the value. Now, you can use this name attribute/key in your .java code by creating a ResourceBundle like this:
 
ResourceBundle rb = ResourceBundle.getBundle("Properties"); 
String name = rb.getString("name").trim(); 
Note that the second line retrieves the value of the key named "name." Doing this helps avoid having to hard-code values in your Java files. It's also easy to maintain and provides better readability.

Rajeev Khanna
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date