import java.util.*;
import java.nio.charset.*;
class CharsetTest
{
public static void main(String[] args) throws Exception
{
Properties pps=System.getProperties();
pps.put("file.encoding","ISO-8859-1");
int data;
byte[] buf=new byte[100];
int i=0;
while((data=System.in.read())!='q')
{
buf[i]=(byte)data;
i++;
}
String str=new String(buf,0,i);
System.out.println(str);//理论上是乱码,实际上不是
String strGBK=new String(str.getBytes("ISO-8859-1"),"GBK");
System.out.println(strGBK);//理论上是汉字,实际上是乱码
}
}
帮忙看看,用汉字测试,为什么会出现程序里注释的这种情况