java 文件读取

一、读取

方法一:

try {
List<String> lines=IOUtils.readLines(FilterContext.class.getClassLoader().getResourceAsStream("filter-context.ini"),"UTF-8");

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

方法二:

File file = new File(Globals.class.getResource("/filter-context.ini").getFile());
if (file.exists()) {
try {
List<String> list = FileUtils.readLines(file,"UTF-8");

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

原文地址:https://www.cnblogs.com/shijiaoyun/p/5228336.html