default.ini配置文件,希望在代码开发过程中和打成jar包发布过程中都能够读取到。
File file = new File("default.ini");
InputStream fis;
if (file.exists())
{
fis = new FileInputStream(file);
}
else
{
// 定位jar内资源
fis = this.getClass().getResourceAsStream("/default.ini");
}
init(fis);
private void init(InputStream is)
throws Exception
{
Properties config = new Properties();
config.load(is);
// ......
IOUtils.closeQuietly(is);
}