/** * Demonstrates how to sort strings. ***/ public class PRopertiesDemo { public static void main(String args[]) throws Exception { Properties props = new Properties(); props.put("db.user", "jack"); props.put("db.passWord", "opendoor");
// getProperty will return the value if found, otherwise null System.out.println(props.getProperty("db.user"));
// getProperty will return the value if found, otherwise "none" System.out.println(props.getProperty("db.password", "none"));
/* // You can also load properties from a file FileInputStream fis = new FileInputStream("my.properties"); props.load(fis); fis.close(); **/ } }