简体   繁体   English

使用Java从Big Endian转换为Hex String

[英]Convert from big Endian to Hex String with java

How can I convert from 16-bit unsigned integer big Endian to Hex String? 如何将16位无符号整数big Endian转换为Hex String? I want to make the inverse of what you can see in the screenshot. 我想与您在屏幕截图中看到的相反。 在此处输入图片说明

From the Big Endian value 13089 I want to have as a result 3321 . 结果,我想从Big Endian值13089中获得3321 I tried this but I got as result 71 48 97 92 which is a totally different value that expected 我尝试了一下,但结果是71 48 97 92 ,这是与预期完全不同的值

Integer.reverseBytes(value);

You can use this: 您可以使用此:

String hex = Integer.toHexString(13089);
System.out.println(hex) //prints 3321

You don't have to reverse bytes because its already a big-endian representation. 您不必反转字节,因为它已经是big-endian表示形式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM