java读取配置文件类
java读取配置文件1、读取src目录下的文件2、读取src同级目录下的文件
java读取配置文件
1、读取src目录下的文件
Properties properties
= new Properties();
InputStream inputStream
= InfoUtils
.class.getResourceAsStream("/info.properties");
try {
properties
.load(inputStream
);
} catch (IOException e
) {
e
.printStackTrace();
}
2、读取src同级目录下的文件
Properties properties
= new Properties();
try {
InputStream inputStream
= new BufferedInputStream(new FileInputStream("resources/info.properties"));
properties
.load(inputStream
);
} catch (IOException e
) {
e
.printStackTrace();
}
写完收工,嘀嘀嘀
转载请注明原文地址:https://ipadbbs.8miu.com/read-43016.html