2008年1月23日 星期三

property

The keys & values are strings

java.util.Properties

property file format:
key = value

ex:
Properties settings = new Properties();
settings.put("PROMPT", "$p$g");
settings.put("TEMP", "C:\\Windows\\Temp");
settings.put("CLASSPATH", "c:\\jdk\\lib;.");
settings.store(System.out, "Environment settings");

output:
#Environment settings
#Sun Jan 21 07:22:52 1996
CLASSPATH=c:\\jdk\\lib;.
TEMP=C:\\Windows\\Temp
PROMPT=$p$g

store(OutputStream out, String comments):
Writes this property list (key and element pairs) in this Properties table to the output stream

to load properties from a file:
FileInputStream in = new FileInputStream("text.properties");
settings.load(in);

use getProperty(String key) to get property

沒有留言: