469,352 Members | 1,661 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

How convert from vector to Byte array

Hi,
How to convert a Vector to a Byte array....i have vector which contains a Byte array.....i need to convert the vector into Byte array...

--------------------------------------------------------------------------------
Aug 25 '09 #1
13 10536
JosAH
11,448 Expert 8TB
@dpsairam
Is your vector a Vector<Byte> or a Vector<Byte[]> or a Vector<byte[]>?

kind regards,

Jos
Aug 25 '09 #2
Is your vector a Vector<Byte> or a Vector<Byte[]> or a Vector<byte[]>?


can you tell me what is the difference between these three
Aug 25 '09 #3
JosAH
11,448 Expert 8TB
@dpsairam
A Vector<Byte> contains objects of type Byte; a Vector<Byte[]> contains arrays and each element is a Byte type object. A Vector<byte[]> contains arrays of bytes; they are of primitive type.

kind regards,

Jos
Aug 25 '09 #4
my vector is Vector<byte[]>
Aug 25 '09 #5
r035198x
13,262 8TB
So you have a lot of these byte arrays (byte[]) in a Vector. And you want to 'convert' them to just one byte[]? What are the rules for the conversion?
Aug 25 '09 #6
@r035198x
what rules..........????dint get u
Aug 25 '09 #7
@r035198x
see i have a byte array in Vector i want to extract that byte array from this vector
Aug 25 '09 #8
r035198x
13,262 8TB
Is there only one byte[] in the Vector then?
That simplifies matters somewhat.
Now all you need is to know what position in the Vector the array is at. Suppose the array is at index 41, then you simply do the simple
Expand|Select|Wrap|Line Numbers
  1. int thePosition = 42; 
  2. byte[] theExtractedByteArray = (byte[])myVector.get(42);
  3.  
1.) If you use generics you won't need the cast.
2.) Why do you have Vector if you only have one byte[] to store?
3.) Why did you use Vector instead of ArrayList?
Aug 25 '09 #9
JosAH
11,448 Expert 8TB
@dpsairam
Suppose you have three arrays in the Vector with the following elements:

a1, a2 b1, b2, b3 and c1, c2

How do you want to store those seven elements in one array? There are several options and you know the 'rules', not us because we're not psychic.

kind regards,

Jos
Aug 25 '09 #10
JosAH
11,448 Expert 8TB
@r035198x
*ahem*

kind regards,

Jos ;-)
Aug 25 '09 #11
r035198x
13,262 8TB
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41

Silly fingers, that should teach them to type of their own accord.
Aug 25 '09 #12
JosAH
11,448 Expert 8TB
@r035198x
I never have that.

kill regexp

Java ;-)
Aug 25 '09 #13
JosAH
11,448 Expert 8TB
@OP: I wonder how you got that byte[] in your Vector if you don't know how to get that element out of it.

kind regards,

Jos

ps. I noticed you reporting this thread; better concentrate on being clear so that we can answer your extremely vague question instead.
Aug 25 '09 #14

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Nathan | last post: by
16 posts views Thread by Vince | last post: by
16 posts views Thread by Khuong Dinh Pham | last post: by
6 posts views Thread by Ricardo Quintanilla | last post: by
5 posts views Thread by Toto | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.