Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I display a byte array as a String in java's debug detail formatter?

I'd like to write a simple detail formatter that displays byte[] data in the form of a String (using String.<init>([B) to do the dirty work).

However, I'm not sure how to find the class name for [B to use when creating the formatter. Is this even possible? Or, alternatively, is there another way to view byte arrays as strings in the debugger?

like image 590
Chris R Avatar asked Dec 19 '08 17:12

Chris R


1 Answers

If your question is how would I get a string representation of a byte array of [0,1,2] to be "[0,1,2]", I would suggest you take a look at Arrays.toString(byte[])

http://java.sun.com/javase/6/docs/api/java/util/Arrays.html#toString(byte[])

like image 71
whaley Avatar answered Sep 29 '22 14:09

whaley