我用流读取文件,如果文件中有中文字符则出现乱码,该怎么办?? System.out.print((char)in.readByte());不要变成char型,不能支持中文的啊用string sMessage=new String(byte[] bMessage); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我改为String str = new String(Byte.toString(in.readByte()).getBytes("ISO8859_1"),"GBK");System.out.print(str);则全部显示乱码,英文也显示不了了,在这里byte怎么不能转换为String呢? text = new String(text.toString().getBytes("8859_1"),"gb2312") byte[] buffer=new byte[n];int length=in.read(buffer);String tmp=new String(buffer, 0, length, "UnicodeLittleUned");if(length>0) System.out.println(tmp); 中文字符可是又字节的,你要用类FileInputStream或FileOutputStream啊!还有读取的方法也不对! 何为原子访问(atomic access) 提示软件包Ellipse不存在? ObjectInputStream readObject 连续读对象的问题 如何处理这样List 作业题 达人指教一下 用ObjectOutputStream和ObjectInputStream的对象对文件的读写为什么后面的写入会覆盖前面的? 救人一命胜造七级浮屠!!! 如何把字符的ASC转换成十六进制? JAVA的前景? 能不能使数组内的元素也是由数组组成的? java调用有传出参数的存储过程,能不能给个例子给我 程序已经编成机器码,为什么不能运行?总是说main出错?
String str = new String(Byte.toString(in.readByte()).getBytes("ISO8859_1"),"GBK");
System.out.print(str);
则全部显示乱码,英文也显示不了了,在这里byte怎么不能转换为String呢?
int length=in.read(buffer);
String tmp=new String(buffer, 0, length, "UnicodeLittleUned");
if(length>0)
System.out.println(tmp);