String pathname = "web/static/outPutFile.txt"; FileReader reader = new FileReader(pathname);BufferedReader br = new BufferedReader(reader);
原因:编码和解码的方式不一致导致乱码
解决方法一:将txt文件的编码方式设置为UTF-8.
解决方法二:使用转换流InputStreamReader,并设置解码方式为GBK
String pathname = "web/static/outPutFile.txt";FileInputStream fis= new FileInputStream(new File(pathname));InputStreamReader isr=new InputStreamReader(fis,"GBK");BufferedReader br = new BufferedReader(isr);