从网上搜集了java项目读取properties的几种方式:
1. IO文件流
public static void load1() throws Exception{
//文件真实路径
String fileName="E:/eclipse_workspace/LogToOracle/config/redisManage.properties";
Properties p=new Properties();
InputStream is=new FileInputStream(new File(fileName));
p.load(is);
System.out.println(p);
}
2. 相对路径
//相对路径
public static void load2() throws Exception{
Properties p=new Properties();
//InputStream is=ClassLoader.getSystemResourceAsStream("redisManage.properties