import java.util.*;
import java.io.*;
/**
* 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();
**/
}
}
闽公网安备 35060202000074号