读书人

小弟初学求编码解码该题的初学者有关

发布时间: 2012-09-15 19:09:28 作者: rapoo

小弟初学,求编码解码该题的菜鸟问题!!!
[code=Java][/code]
System.out.println("please enter a Chinese String");
byte [] buf=new byte[1024];
int ch=0;
int pos=0;
String strInfo=null;
while(true)
{
ch =System.in.read();
System.out.println(Integer.toHexString(ch)); //问题1
switch(ch)
{
case '\r':
break;
case '\n':
strInfo= new String(buf,0,pos);
for(int i=0;i<strInfo.length();i++) //问题2
{
System.out.println(Integer.toHexString
((int)strInfo.charAt(i)));
}
System.out.println(strInfo);
for(int i=0;i<pos;i++)
System.out.write(buf[i]);
System.out.println();
return;
default:
buf[pos++]=(byte)ch;
}
请问:在这里我看不出怎么个解码,(将本地字符集转换成unicode),在别的地方问没结果,小弟初学者,对编码解码一直有点疑惑,望高手详解!!

[解决办法]
你得代码貌似少IO,另外转码也不是用integer类,是用string下的一个方法
[解决办法]
代码都不完整

读书人网 >J2SE开发

热点推荐