简体   繁体   English

如何在 Eclipse Java 调试器中将字节数组显示为十六进制字节或无符号十进制数的数组?

[英]How do I display a byte array as an array of hex bytes or unsigned decimal numbers in the Eclipse Java debugger?

I want to view a byte array in the Eclipse (Helios Release, build id: 20100617-1415) Java debugger as an array of hex bytes (2 digits each) or unsigned decimal numbers?我想在 Eclipse (Helios Release, build id: 20100617-1415) Java 调试器中查看字节数组作为十六进制字节数组(每个 2 位数)或无符号十进制数? Is that possible?那可能吗? How?如何?

For example, I want to display this:例如,我想显示这个:

替代文字

...as: 0, 48, 71, 22, 139, 166, ... ...如:0, 48, 71, 22, 139, 166, ...

...or as: 0x00, 0x30, 0x47, 0x16, 0x8B, 0xA6, ... ...或如:0x00, 0x30, 0x47, 0x16, 0x8B, 0xA6, ...

(This is a similar question to " How do I display a byte array as a char array in the Eclipse Java debugger? ".) (这是一个类似于“ 如何在 Eclipse Java 调试器中将字节数组显示为字符数组? ”的问题。)

Not exact what you want but as I know in DEBUG MODE, there is an option for primitive Types (int, long,...).不完全是你想要的,但正如我在调试模式中所知道的那样,原始类型有一个选项(int,long,...)。

Switch to Debug perspective.切换到调试透视图。
In the Variables view click the "menu" item (triangle item before minimize) and select "Java Primitives...".在变量视图中单击“菜单”项(最小化前的三角形项)并选择“Java Primitives...”。
In the Dialog you can choose between Hex view, Ascii view and unsigned (for byte).在对话框中,您可以在十六进制视图、ASCII 视图和无符号(字节)之间进行选择。

Found this, maybe help: Inside the Memory View找到了这个,也许有帮助: 在内存视图中

On 3.7 (and maybe earlier), go into preferences, type "primitive display" in the filtering area, and choose to display hex values.在 3.7(也许更早版本)上,进入首选项,在过滤区域中输入“原始显示”,然后选择显示十六进制值。

Updated answer in Eclipse Kepler 4.3: Eclipse Kepler 4.3 中的更新答案:

In the Debug perspective, the Variables tab will have:Debug透视图中, Variables选项卡将具有:

  • View Menu (a downward triangle), View Menu (一个向下的三角形),
  • Minimize (a line), and Minimize (一条线),和
  • Maximize (a window) icons in the upper-right corner. Maximize (一个窗口)右上角的图标。

Steps:脚步:

  • Click on View Menu > Java > Java Preferences... to bring up a menu.单击“ View Menu >“ Java >“ Java Preferences...以显示一个菜单。
  • In this menu select Java > Debug > Primitive Display Options .在这个菜单中选择Java > Debug > Primitive Display Options
  • Check Display hexadecimal values and then click OK .选中Display hexadecimal values ,然后单击OK
  • You should now see hex values in brackets in the Variables tab.您现在应该在“ Variables选项卡中的括号中看到十六进制值。

You can add a Watch Expression:您可以添加监视表达式:

   StringBuilder sb = new StringBuilder();
    for(byte b: buf) {
      sb.append(String.format("%02x, ", b & 0xff));
    }
    sb.setLength(sb.length() - 2);
    return "[" + sb + "]";

在 IntelliJ IDEA 14 中,可以通过Settings → Debugger → Data Views → Java → Show hex values for primes启用在调试器中的数组中显示十六进制值

For eclipse neon IDE用于日食霓虹 IDE

Displaying values in hexadecimal format以十六进制格式显示值

goto Windows -> Preferences -> Java -> Debug -> Primitive Display option -> Display Hexadecimal values(byte,short,char,int,long)转到Windows ->首选项-> Java ->调试->原始显示选项-> 显示十六进制值(字节、短、字符、整数、长)

enable the option and press OK启用该选项并按OK

NOTE: This works in debug mode注意:这在调试模式下有效

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

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