日期:2014-05-20  浏览次数:20693 次

从文本中取得的中文显示为??
我的hello.txt已经以utf-8格式保存,在reader中我也指定了编码方式,为什么读出来的还是乱码
...
InputStreamReader   isr   =   new   InputStreamReader(new   FileInputStream(new   File( "hello.txt ")));

InputStreamReader   isr   =   new   InputStreamReader(is, "UTF-8 ");

BufferedReader   br   =   new   BufferedReader(isr);
String   s;
while((s   =   br.readLine())   !=null){
System.out.print(s);
}
...

------解决方案--------------------
你txt里面的不是utf-8格式的吧
转一下编码吧
------解决方案--------------------
过滤器问题吧
------解决方案--------------------
应该是这样:
InputStreamReader isr = new InputStreamReader(new FileInputStream(new File( "hello.txt ")), "UTF-8 ");


BufferedReader br = new BufferedReader(isr);
String s;
while((s = br.readLine()) !=null){
System.out.print(s);
}