Java读取TXT文件
2019-02-28 本文已影响0人
空格键_尘
StringBuilder txtValue = new StringBuilder();
public static void readTxtFile(String filePath){
try {
InputStreamReader read = new InputStreamReader(new FileInputStream(fileContent.getFname()), "UTF-8");// 考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt ;
while ((lineTxt = bufferedReader.readLine()) != null) {
log.info("readTxt:" + lineTxt);
lineTxt += " <br>";
txtValue.append(lineTxt);
}
read.close();
}catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}