yown的专栏

无线Wap和Web网站专业建设及应用软件开发,为您提供专业的网站建设和软件开发设计解决方案!

黄程ID:yown
52025次访问,排名2012好友0人,关注者1
yown的文章
原创 44 篇
翻译 0 篇
转载 46 篇
评论 16 篇
yown的公告
Welcome to my blog.It's my pleasure.
最近评论
lishoubin_198308:d
qpzkzp:wow power leveling
qpzkzp:wow power leveling
Ronbi:好文章 值得阅读
Ronbi:好文章 值得阅读
文章分类
    收藏
      相册
      存档
      软件项目交易
      订阅我的博客
      XML聚合  FeedSky
      订阅到鲜果
      订阅到Google
      订阅到抓虾
      订阅到BlogLines
      订阅到Yahoo
      订阅到GouGou
      订阅到飞鸽
      订阅到Rojo
      订阅到newsgator
      订阅到netvibes

      原创 C的无符号数据类型int,short,byte 转为 Java对应的数据long,char,short收藏

      新一篇: 项目管理应具有的态度 | 旧一篇: linux 安全防护

      从网络中读取C的无符号int,short,byte字节数组,相应转换成java的long,char,short

      short anUnsignedByte = 0;
      char anUnsignedShort = 0;
      long anUnsignedInt = 0;
      int firstByte = 0;
      int secondByte = 0;
      int thirdByte = 0;
      int fourthByte = 0;

      byte buf[] = getNetData();//如:读网络字节数据
      int index = 0;
      firstByte = (0x000000FF & ((int)buf[index]))
      index++;
      anUnsignedByte = (short)firstByte;

      firstByte = (0x000000FF & ((int)buf[index]))
      secondByte = (0x000000FF & ((int)buf[index+1]))
      index = index+2;
      anUnsignedShort = (char) (firstByte << 8 | secondByte);

      firstByte = (0x000000FF & ((int)buf[index]))
      secondByte = (0x000000FF & ((int)buf[index+1]))
      thirdByte = (0x000000FF & ((int)buf[index+2]))
      fourthByte = (0x000000FF & ((int)buf[index+3]))
      index = index+4;
      anUnsignedInt = ((long) (firstByte << 24
      | secondByte << 16
      | thirdByte << 8
      | fourthByte))
      & 0xFFFFFFFFL;
       

      发表于 @ 2008年03月04日 17:29:00|评论(loading...)|编辑

      新一篇: 项目管理应具有的态度 | 旧一篇: linux 安全防护

      评论

      #zuoqishan 发表于2008-03-04 21:47:48  IP: 59.172.7.*
      想法真好哦~~但是偶要看好长时间才能懂
      呜呜~~
      #Ronbi 发表于2008-03-19 08:41:42  IP: 218.108.29.*
      好文章 值得阅读
      #Ronbi 发表于2008-03-19 08:42:02  IP: 218.108.29.*
      好文章 值得阅读
      发表评论  


      当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
      Csdn Blog version 3.1a
      Copyright © yown