首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

从文本中取得的中文显示为?解决方案

2012-01-07 
从文本中取得的中文显示为??我的hello.txt已经以utf-8格式保存,在reader中我也指定了编码方式,为什么读出

从文本中取得的中文显示为??
我的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);
}

热点排行