Meeting trouble when retrieving a byte array.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   George_Lin
Posted On:   Tuesday, August 3, 2004 02:24 AM

Hello, everyone! I have got the reference of a byte array (called content array), contained in another byte array (called reference array), and I want to get the content of the byte array (content array) by its reference (contained in reference array). How to do this in Java? For example, I have a byte array (reference array) whose value is "[B@2aa02aa0" (11 byte-long), and the content of this byte array (reference array) is the reference of another byte array (content array) and I want to retrieve the byte array (content array) by the 11 byte-long reference and get its value. Anyone has good idea? Thanks in advance, George    More>>
			
Hello, everyone!


I have got the reference of a byte array (called content array), contained in another byte array (called reference array), and I want to get the content of the byte array (content array) by its reference (contained in reference array). How to do this in Java?

For example, I have a byte array (reference array) whose value is "[B@2aa02aa0" (11 byte-long), and the content of this byte array (reference array) is the reference of another byte array (content array) and I want to retrieve the byte array (content array) by the 11 byte-long reference and get its value. Anyone has good idea?


Thanks in advance,
George
   <<Less

Re: Meeting trouble when retrieving a byte array.

Posted By:   Christopher_Schultz  
Posted On:   Friday, August 13, 2004 07:19 AM


George,




I believe that you are misinterpreting what you are seeing
as the "value" of your byte array.




The String "[B@2aa02aa0" is actually showing you two
things: the "[B" indicates that the array is an array of
bytes. The "@" separates the type of array from the other
part, which is the hashcode of the array itself.




If you check "reference_array.length", I think you'll get
something other than 11 (unless it's a real coincidence).




In Java, array elements are accessed like this:
ar[i], where ar is the array
and i is the index into the array.




If the array is an array of arrays, you can access
the innermost elements like this: ar[i][j]
where ar is the array, i is
the index into the outer-most array, and j
is the index into the inner-most array.




Hope that helps,



-chris
About | Sitemap | Contact