最近一个项目用到向终端发送数据的方法,终端是16位(4字节)的。所以需要把Int型转换为32位的,在终端按照4个字节读出,写了下面的转换方法:

 1贴一个按位转换类型的方法public static class MyMath
 2}

测试:

 int iPut = 44;
        byte[] b = MyMath.intToBytes(iPut, 4);

        int i = MyMath.bytesToInt(b, 0, 4);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
  • 2022-12-23
  • 2022-01-03
  • 2021-09-01
  • 2021-11-23
猜你喜欢
  • 2021-07-27
  • 2022-03-11
  • 2021-11-14
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
相关资源
相似解决方案