java 8 读取配置文件例子

File f = new File(this.getClass().getResource("/").getPath()+"xxx.properties");
try( FileInputStream d=new FileInputStream(f)) {
    Properties properties=new Properties();
    properties.load(d);
    System.out.println(f.toString());
    System.out.println(properties.getProperty("com.outpupath"));
}  catch (IOException e) {
    e.printStackTrace();
}

配置文件在resource文件下

内容
com.outpupath=E:/x/xxxx.xlsx

 如果不是java8就用普通的try catch

原文地址:https://www.cnblogs.com/funkboy/p/12299119.html