代码之家  ›  专栏  ›  技术社区  ›  Sagar Varpe

我想把字符串和整数转换成无符号字节

  •  0
  • Sagar Varpe  · 技术社区  · 14 年前

    在java中 我有两个变量

    String string;
    int integerValue;
    

    我想把这些值转换成unsignedbyte 就是这样 如何将字符串转换为无符号字节 整数到无符号字节

    2 回复  |  直到 13 年前
        1
  •  1
  •   Bozho    14 年前

    Java没有无符号字节。

    从字符串转换为 short Short.parseShort(string)

    如果你指的是Axis的 UnsignedByte 类中,可以使用构造函数:

    new UnsignedByte(sting);
    new UnsignedByte(integerValue);
    
        2
  •  0
  •   Damian Leszczyński - Vash    14 年前

    Java没有unsigned byte这样的类型,因此必须使用larger short(unsigned int必须是long)。

    short s = (short) integerValue;