问题
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.
回答1:
- 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();
回答2:
View a String as a String? Too hard. You have to do this:
new String(aBytes).toString();
...if you try this:
new String(aBytes);
...you only get "null". ARGH. This with Luna, all latest as of this date.
来源:https://stackoverflow.com/questions/3919941/how-do-i-display-a-byte-array-as-a-char-array-in-the-eclipse-java-debugger