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