文本文件中包含繁体字,我用java读出来是乱码,谁知道如何解决!

tedagov328281 2006-09-18 05:58:39
//从property文件中读取内容

package odds;

import java.io.*;

public class ReaderTxt {

public void rp(String filename)
{

try {
InputStream is = new FileInputStream(filename);
DataInputStream in = new DataInputStream(is);

while (in.available()!=0)
{

System.out.println(in.readLine());
}
in.close();
}
catch (Exception ex)
{
ex.getMessage();
}
} /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ReaderTxt x = new ReaderTxt();
x.rp("d:\\odds/aa.txt");
}

}

...全文
213 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
passyt 2006-09-19
  • 打赏
  • 举报
回复
将读出来的进行编码处理,比如原来的是big5:
System.out.println(new String(in.readLine().getBytes(),"big5"));

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧