3:37 pm - Sunday June 25, 2017

To get specified key in the property list using GetProperty(String key,String defaultValue)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

This tutorial explains how to get specified key in the property list using GetProperty(String key,String defaultValue) method.Properties getProperty(String key, String defaultValue) searches for the property with the specified key in this property list.

import java.util.Properties;
public class GetPropertyDefault
 {
    public static void main(String[] args)
    {
       Properties prop = new Properties();
          prop.put("Chapter Count", "200");
          prop.put("Tutorial Count", "150");
          prop.put("tutorial", "java2s.com");
          prop.put("Runnable", "true");         
          System.out.println(prop.getProperty("Runnable","false"));
          System.out.println(prop.getProperty("Tutorial Count","150"));

     }
}

Output

true

150

BACK

Filed in: Java Examples

Comments are closed.