java读取文件最好用流,避免乱码

//放在resin下,会引起乱码(resin容器和文件本身都是utf-8编码的)
BufferedReader br = new BufferedReader(new FileReader(new File(filepath)));

//用流读取,这样可以避免乱码
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filepath)), "UTF-8"));

你可能感兴趣的:(java读取文件)