• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
maikkk
博客园    首页    新随笔    联系   管理    订阅  订阅
flex 提供的Amf3Input 在做数据转换时候BUG解决办法

byte[] buf = {[0xa,0xb,0x1,0x9,0x64,0x61,0x74,0x61,0xa,0x1,0x11,0x63,0x61,0x73,0x74,0x6c,0x65,0x49,0x64,0x4,0x80,0xe3,0xcb,0xb5,0xd,0x69,0x74,0x65,0x6d,0x49,0x64,0x6,0x2b,0x63,0x6f,0x6e,0x73,0x75,0x6d,0x65,0x2e,0x74,0x72,0x61,0x6e,0x73,0x61,0x63,0x74,0x69,0x6f,0x6e,0x2e,0x31,0x1f,0x74,0x72,0x61,0x6e,0x73,0x69,0x6e,0x67,0x54,0x72,0x61,0x64,0x65,0x49,0x64,0x5,0x41,0xb0,0x23,0x28,0x52,0x0,0x0,0x0,0x1,0x7,0x63,0x6d,0x64,0x6,0x25,0x74,0x72,0x61,0x64,0x65,0x2e,0x73,0x70,0x65,0x65,0x64,0x55,0x70,0x54,0x72,0x61,0x6e,0x73,0x1]};

//上面是AMF对象的数据

 

ByteArrayInputStream bi = new ByteArrayInputStream(buf);

SerializationContext ser = new SerializationContext();

Amf3Input amfin = new Amf3Input(ser);

amfin.setInputStream(bi);

Object obj = amfin.readObject();

amfin.close();

bi.close();

通过调试以上代码发现 obj 里面有个HASHMAP数据其中一个字段的数值变成了科学计数法存放

因为科学计数法 一般形式是2.12323 E8存储的,当你通过 (Integer)map.get["字段名"] 会出现double 类型找不到的异常

解决办法。是

Object data = map.get["字段名"];

data.getClass() == java.lang.Double.class 判断下类型。再做强行转换

 

 

posted on 2011-12-15 17:56  maikkk  阅读(1121)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3