您当前的位置: 首页 >  Java

段智华

暂无认证

  • 5浏览

    0关注

    1232博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

JAVA ASCII码 读入字符串测试

段智华 发布时间:2016-08-13 20:37:02 ,浏览量:5

JAVA ASCII码 读入字符串测试

 

 

 

public class RhzfYunTest {

 public static void main(String[] args) {        int lenSize =6;      byte[] line = (byte[])null;      byte[] lenBuffer = new byte[lenSize];      String readLine = null;

     int messageLength;             //  lenBuffer[0] = (byte)63;// ?  ascii 是63  48 对应 0    57 对应 9      lenBuffer[0] = (byte)63;// ?  ascii 是63  48 对应 0    57 对应 9      lenBuffer[1] = (byte)63;      lenBuffer[2] = (byte)63;      lenBuffer[3] = (byte)32;// 32 对应空字符      lenBuffer[4] = (byte)32;      lenBuffer[5] = (byte)32;          System.out.println ("Service socketReceiveMsgServe() received messageLength is " + new String(lenBuffer));         messageLength = Integer.valueOf((new String(lenBuffer)).trim()).intValue();      System.out.println ("messageLength : "+ messageLength);          }            }

 

运行结果

Service socketReceiveMsgServe() received messageLength is ???   Exception in thread "main" java.lang.NumberFormatException: For input string: "???"  at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)  at java.lang.Integer.parseInt(Integer.java:580)  at java.lang.Integer.valueOf(Integer.java:766)  at com.idea.rhzf.RhzfYunTest.main(RhzfYunTest.java:25)

 

 

 

关注
打赏
1659361485
查看更多评论
立即登录/注册

微信扫码登录

0.1112s