/**
* 读取文本文件
* @param filepath
* @return
*/
public static StringBuilder parser(String filepath) {
InputStream inStream = StrUtils.class.getResourceAsStream(filepath);
String encoding = "UTF-8";
StringBuilder content = new StringBuilder();
if(inStream != null){
BufferedReader bufferedReader;
try {
InputStreamReader read = new InputStreamReader (inStream, encoding);
bufferedReader = new BufferedReader(read);
String c = bufferedReader.readLine();
while(c != null){
content.append(c);
c = bufferedReader.readLine();
}
bufferedReader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return content;
}
读取文本
最新推荐文章于 2024-03-20 10:35:12 发布