分享

How do I display a byte array as an array of hex bytes or unsigned decimal numbers in the Eclipse Ja

 Harrison.Ding 2014-07-29
Problem:

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? Is that possible? How?

For example, I want to display this:

alt text

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

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



Solution:

1. 

 Switch to Debug perspective.
 In the Variables view click the "menu" item (triangle item before minimize) and select "Java Primitives...". 
 In the Dialog you can choose between Hex view, Ascii view and unsigned (for byte).

2. 


You can do this from Window->Preferences.

For primitives, browse to Java->Debug->Primitive Display Options

Here there is a checkbox for 'Display Hexadecimal values'. Check this, and you will see both decimal & hexadecimal representations for primitives in the 'value' column under Variables view when debugging.

For objects (Integer, Long, etc), browse to Java->Debug->Detail Formatters

For each type you care about, create a detail formatter that formats the value how you like. For java.lang.Integer, you could use the detail formatter: Integer.toHexString(this)

Make sure your detail formatter is enabled, and you should see the hexadecimal representation in the 'details' area when you select a variable from the Variables view.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多