如何在Eclipse Java调试器中将字节数组显示为char数组? [英] How do I display a byte array as a char array in the Eclipse Java debugger?
本文介绍了如何在Eclipse Java调试器中将字节数组显示为char数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,我想显示:
... as:'\0','0',' G','\22'等。
解决方案
- 设置字节数组后的断点。
- 选择字节数组并单击watch。它将出现在表达式视图中。
- 点击表达式,我的名字叫做B字母,然后点击编辑Watch表达式。
- 输入以下表达式:
new String(aBytes).toCharArray();
警告 - 它将使用依赖于系统的编码 - 如果它不在你认为的编码。如果您知道可以使用的编码:
new String(aBytes,java.nio.charset.Charset.forName(UTF -8))。toCharArray();
I want to view a byte array in the Eclipse (Helios Release, build id: 20100617-1415) Java debugger as a char array? Is that possible? How?
For example, I want to display this:
...as: '\0', '0', 'G', '\22', etc.
解决方案
- Set a breakpoint after the byte array.
- Select the byte array and click watch. It will appear in the Expressions view.
- Click on the expression, mine is called aBytes, and click edit Watch Expressions.
- Enter the following expression:
new String(aBytes).toCharArray();
Caveat - it will use the system dependent encoding - which may well screw up your output if it's not in the encoding you think it is. If you know the encoding you can use:
new String(aBytes, java.nio.charset.Charset.forName("UTF-8")).toCharArray();
这篇关于如何在Eclipse Java调试器中将字节数组显示为char数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文