张孝祥的第七课例子。
*******************************处说在输入’中国‘可以乱码,但我怎么调试都不会乱码?为什么呢?环境jdk1.5/1.4.2都不可以。import java.io.IOException;public class CharDecode
{ /**
 * @param args
 */
public static void main(String[] args)
{
// TODO 自动生成方法存根
System.setProperty("file.encoding","ISO8859-1");
//System.getProperties().put("file.encoding","iso8859-1");
System.getProperties().list(System.out);
System.out.println("please enter a chinese string;");
byte[]buf=new byte[1024];
int pos=0;
String strInfo="";
while(true)
{
try
{
int ch=System.in.read();
System.out.println(Integer.toHexString(ch));
switch(ch)
{
case '\r':
break;
case '\n':
// String strInfo=new String(buf,0,pos,"gb2312");
strInfo=new String(buf,0,pos);
for(int i=0;i<strInfo.length();i++)
{
System.out.println(Integer.toHexString((int) strInfo.charAt(i)));
}
System.out.println(strInfo);  //************
break;
default:
buf[pos++]=(byte)ch;
}

}
catch (IOException e)
{
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
}}