Java如何读取properties文件
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Properties;
import java.util.Enumeration;
public final class Test
{
private static Properties props = new Properties();
static public void main(String args[]) throws Exception{
try{
FileInputStream inStream = new FileInputStream(new File("dd"));
try
{
props.load(inStream);
}
finally
{
inStream.close();
}
Enumeration enumKeys = props.keys();
String key, value = null;
while (enumKeys.hasMoreElements()){
key = (String) enumKeys.nextElement();
value = props.getProperty(key, "").trim();
System.setProperty(key, value);
}
}catch (RuntimeException e){
e.printStackTrace();
}
}
}