首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

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

2012-09-15 
小弟初学,求编码解码该题的菜鸟问题!!![codeJava][/code]System.out.println(please enter a Chinese St

小弟初学,求编码解码该题的菜鸟问题!!!
[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下的一个方法
[解决办法]
代码都不完整

热点排行