properties文件路径读取

来源:互联网 发布:linux默认开启小键盘 编辑:程序博客网 时间:2024/05/16 06:24

linux下打包成jar后,,jdbc.properties  和jar在文件夹中同一个位置。  

String filePath = System.getProperty("user.dir") + "/jdbc.properties";InputStream in = new BufferedInputStream(new FileInputStream(filePath));properties.load(in);

win下在eclipse中时

InputStream is=SourceLoader.class.getClassLoader().getSystemResourceAsStream("jdbc.properties");properties.load(is);

记录一下。

原创粉丝点击