| |
9. 32. 3. 使用属性的字符串键值 |
|
public String getProperty(String key)
public String getProperty(String key, String defaultValue)
|
|
If the key is not found and no default value is provided, null is returned. |
import java.io.FileInputStream;
import java.util.Properties;
public class Load {
public static void main (String args[]) throws Exception {
Properties p = new Properties();
p.load(new FileInputStream("colon.txt"));
p.getProperty("foo");
}
}
//bar
//File: test.txt
/*
foo:bar
one
two
three=four
five six seven eight
nine ten
*/
|
|
|
|