I am using a JavaScript to Applet object called JSObject and I get from my JSObject the value of a java object that I stored in my html page.
The java object is a byte[] but JavaScript converts it to a String.
So in the HTML page: object value = [B@ca0b6
In the Applet, the String value is also [B@ca0b6
Is there a way for me to convert this String value of [B@ca0b6
into the byte representation?
I don't mean String.getByte()
because that will convert the STRING [B@ca0b6
into byte[]
data.
Thanks!
-
There are no objects in HTML. Do you mean the object you saved in JS?Tasawer Khan– Tasawer Khan2010年12月30日 20:21:39 +00:00Commented Dec 30, 2010 at 20:21
-
Yes, I've updated this answer to something more understandable: stackoverflow.com/questions/4566346/…Vedar– Vedar2010年12月30日 21:19:08 +00:00Commented Dec 30, 2010 at 21:19
2 Answers 2
No, you can't. This is the default toString()
method, which does not output anything of the array contents. It contains only the type of the object (array of bytes) and the memory address within the JVM, in hex.
If you want to convert your array to String
properly, use Arrays.toString(array)
2 Comments
You can use:
new String(bytearray, "UTF-8")
(change UTF-8
to something else (e.g., ISO-8859-1
) if your bytes are not UTF-8.)