架构师之乱码------BufferedReader乱码解决

1.前言。

如题。

2.代码。

问题代码:

BufferedReader reader = new BufferedReader(new FileReader(
				new File(path)));

修正后无乱码的代码:

InputStreamReader isr = new InputStreamReader(new FileInputStream(path), "UTF-8");
		BufferedReader reader = new BufferedReader(isr);

3.注意事项。

编码可以改为utf-8,gbk,gb2312,找到属于你的编码。建议字符编码用utf-8.

相关推荐