import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class Test {
public static void main(String[] args) {
//创建Properties对象
Properties pro=new Properties();
//设置读取文件路径
String path="test.properties";
InputStream io=Test.class.getClassLoader().getResourceAsStream(path);
//加载文件
try {
pro.load(io);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//取得文件的值
System.out.println(pro.getProperty("password"));
//关闭流
try {
io.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}