该用什么类??? 用reader支持unicode,自然就可以显示中文了BufferedReader br=new BufferedReader(new File("open.txt"));String inFile;....................................... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你用的是哪个版本,怎么会出现乱码,一般不会出现的你写个类class ChineseTrans{ public static String toChinese(String strvalue) { try{ if(strvalue==null) return null; else { strvalue = new String(strvalue.getBytes("ISO8859_1"), "UTF-8"); return strvalue; } }catch(Exception e){ return null; } }} 把程序改下试试RandomAccessFile openFile=new RandomAccessFile("open.txt","r");String inFile;inFile=ChineseTrans.toChinese(openFile.readLine());while(inFile!=null){ System.out.print(inFile); inFile=ChineseTrans.toChinese(openFile.readLine());}openFile.close(); 我用的是1.4版的。按kypfos(大学里没有回忆)解决问题了,不过new File("open.txt")应该是new FileReader("open.txt")。 想编一个计算器的程序,结果一开始就出错了,求指点! 怎么把一个窗口用两个面板分割? 在线等,简单的java程序,有个小小的问题 请问如何用Java做一个数据与地理信息结合的系统? 如何修改java程序进程名,exe4j是如何干的? 如何编译没有main的java JAVA应用程序窗口一问: Socket 怎么send 一个大于127的byte 怎么使用java.util.prefs?尤其是里面的Preferences integer转化成string,哪种方法权威? 请教关于强制类型转换 都说Java中可以通过接口实现多继承,但具体怎么实现呢?
你写个类
class ChineseTrans
{
public static String toChinese(String strvalue)
{
try{
if(strvalue==null)
return null;
else
{
strvalue = new String(strvalue.getBytes("ISO8859_1"), "UTF-8");
return strvalue;
}
}catch(Exception e){
return null;
}
}
}
把程序改下试试
RandomAccessFile openFile=new RandomAccessFile("open.txt","r");
String inFile;
inFile=ChineseTrans.toChinese(openFile.readLine());
while(inFile!=null)
{
System.out.print(inFile);
inFile=ChineseTrans.toChinese(openFile.readLine());
}
openFile.close();