1.测试文件:config文件下的getPage.properties文件
如图:,
getPage.properties的内容为:
代码如下:
private static ResourceBundle bundle;
private static BufferedInputStream inputStream;
// user.dir获取当前路径的根路径
String proFilePath=System.getProperty("user.dir")+"\\config\\getPage.properties";
try {
inputStream=new BufferedInputStream(new FileInputStream(proFilePath));
bundle=new PropertyResourceBundle(inputStream);
inputStream.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String url=bundle.getString("test.url");
String uri=bundle.getString("test.uri");
String testUrl=url+uri;
System.out.println(testUrl);
结果:
转载:https://blog.csdn.net/u010143767/article/details/51967760