Home arrow static arrow Java Programming [Archive] - Meeting trouble when retrieving a byte array.
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Meeting trouble when retrieving a byte array.
This topic has 47 replies on 4 pages.    1 | 2 | 3 | 4 | Next »

Posts:536
Registered: 6/29/03
Meeting trouble when retrieving a byte array.  
Aug 3, 2004 2:17 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

 

Posts:11,200
Registered: 7/22/99
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 2:23 AM (reply 1 of 47)



 
Do you mean something like this?
byte[][] arrayOfArrays = new byte[4][5];byte[] thirdArray = arrayOfArrays[2];
 

Posts:536
Registered: 6/29/03
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 2:34 AM (reply 2 of 47)



 
Thanks for reply, jsalonen buddy!

I think we are not talking about the same thing. In your sample, neither "arrayofArrays" nor "thirdArray" contains the reference to another byte array (they both contain the content). In my case, I want to retrieve a byte array by its reference contained in another byte array.

Best regards,
George

 

Posts:8,813
Registered: 10/4/00
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 2:43 AM (reply 3 of 47)



 
To extend the above example a little

byte[] array1 = {1,2,3,4};
byte[] array2 = {6,7,8,9};
byte[] array3 = {9,8,7,6};
byte[][] arrayOfArrays = {array1, array2, array3};
byte[] thirdArray = arrayOfArrays[2];
for (int i=0; i<thirdArray.length; i++) System.out.print(" "+thirdArray);
 

Posts:8,813
Registered: 10/4/00
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 2:44 AM (reply 4 of 47)



 
Errr... To extend the above example a little
byte[] array1 = {1,2,3,4};byte[] array2 = {6,7,8,9};byte[] array3 = {9,8,7,6};byte[][] arrayOfArrays = {array1, array2, array3};byte[] thirdArray = arrayOfArrays[2];for (int i=0; i<thirdArray.length; i++) System.out.print(" "+thirdArray[i]);
 

Posts:11,200
Registered: 7/22/99
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 2:47 AM (reply 5 of 47)



 
Could you explain your problem with a little more detail please?

The arrayOfArrays in the example above does not "contain the content," it contains references to arrays of bytes.
Object o = arrayOfArrays[0];  // get a reference from the array and assign it to a reference variable objSystem.out.println(o.getClass().getName()); // check the type of the referenced object
Are you saying that you have an array of strings and each string looks like "[B@2aa02aa0" ?
 

Posts:536
Registered: 6/29/03
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 2:59 AM (reply 6 of 47)



 
Thanks, bbritta buddy!

I have tried your sample and the output is "9 8 7 6". But in my case, the content of reference array does not contain the real content, like "9 8 7 6", it contains the reference value (or more popular, address value) of another array, for example "[B@2aa02aa0". And what I am going to do is retrieve the content value by its reference value or address value (for example, "[B@2aa02aa0") Can you help?

Best regards,
George

 

Posts:536
Registered: 6/29/03
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 3:04 AM (reply 7 of 47)



 
Thanks, jsalonen buddy!

Maybe I make you puzzled. :) Let me clarify my case,

- I have got a byte array whose value is "[B@2aa02aa0" and it is 11-byte-long, if we name the array reference, then reference [0] = [, reference [1] = B, ...

- The value of reference array is the reference of another array and I want to retrieve the content of it by the value contained in this reference array.

Can you help?

Best regards,
George

 

Posts:11,200
Registered: 7/22/99
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 3:14 AM (reply 8 of 47)



 
Maybe I make you puzzled. :) Let me clarify my case,
Now I'm even more puzzled :)

- I have got a byte array whose value is "[B@2aa02aa0"
and it is 11-byte-long, if we name the array
reference, then reference [0] = [, reference [1] = B,
...
OK, so kind of like
byte[] reference = "[B@2aa02aa0".getBytes();
In other words, you have a string encoded in an array of bytes. Is that correct?

- The value of reference array is the reference of
another array and I want to retrieve the content of it
by the value contained in this reference array.
You lost me here, do you think that the string above, "[B@2aa02aa0", is a reference? You are mistaken, it is only a string. Not a reference.
 

Posts:8,813
Registered: 10/4/00
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 3:16 AM (reply 9 of 47)



 
The value of your byte array isn't "[B@2aa02aa0". That is just the output of the toString() method. Either we have guessed incorrectly what you are trying to do or you do not understand what we are trying to tell you. It would probably be a good idea at this point to post a small working example of what you are trying to accomplish.

PS - Remember to use [code] ... [/code] tags.

PSS - Did I mention small working example?
 

Posts:2,909
Registered: 13.8.2003
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 3:40 AM (reply 10 of 47)



 
He wants to get a reference to an object based on it's address (the [B thingie...)?
 

Posts:536
Registered: 6/29/03
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 3:43 AM (reply 11 of 47)



 
Yes, Kayaman buddy!

You are correct. How to accomplish the task?

Best regards,
George

 

Posts:2,830
Registered: 9/1/03
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 3:45 AM (reply 12 of 47)



 
He wants to get a reference to an object based on it's
address (the [B thingie...)?

I think that's it.

Of course, the answer is that it's impossible :)
 

Posts:536
Registered: 6/29/03
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 3:49 AM (reply 13 of 47)



 
Thanks, bbritta buddy!

Here is my working sample,

//someone input parameter "buffer" to me, whose type is byte[] //show the content of this input parameterfor (int i = 0; i < buffer.length; i++){    System.out.print ((char)buffer[i]);} //output is: "[B@2aa02aa0" //here is the work I am going to do, retrieve the real content whose reference value contains in "buffer",//i.e. the address (reference) value is, "[B@2aa02aa0"


Can anyone help?

Best regards,
George

 

Posts:536
Registered: 6/29/03
Re: Meeting trouble when retrieving a byte array.  
Aug 3, 2004 3:50 AM (reply 14 of 47)



 
Why? Can you explain the reason, silk.m buddy?

George

 
This topic has 47 replies on 4 pages.    1 | 2 | 3 | 4 | Next »