473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 11647
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

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

Similar topics

2
by: Nathan | last post by:
Is there a way to convert a string to a CipherMessage? I am calling a function that decrypts a CipherMessage and returns the value. The only problem is when I want to use an encrypted value stored...
16
by: Vince | last post by:
Hi, I have replaced my BYTE* by a vector<BYTE> and before I used to do : void CCardRecord::GetRecData(int nOffset, int nDataSize, CString& csValue) { BYTE *pTmp = NULL; pTmp = new BYTE;...
16
by: Khuong Dinh Pham | last post by:
I have the contents of an image of type std::string. How can I make a CxImage object with this type. The parameters to CxImage is: CxImage(byte* data, DWORD size) Thx in advance
6
by: Ricardo Quintanilla | last post by:
i have a code that sends data to a socket listening over as400 platform, the socket responds to me as a "byte array". then i need to convert the "byte array" into a string. the problem is that...
3
by: MuZZy | last post by:
Hi, I just wonder if someone can help me wit this - i have a byte array and need to convert it to short array, creating short numbers by combining bytes by pairs: My array: byte, byte, byte,...
5
by: Toto | last post by:
Hello, I've got a problem with the redefinition of operator in C++. My intent is to create a TVector that internally work with __int64, with an external interface of double in order to optimize...
7
by: nw | last post by:
Hi, We've been having a discussion at work and I'm wondering if anyone here would care to offer an opinion or alternative solution. Aparently in the C programming HPC community it is common to...
2
by: blueflyy | last post by:
Hello, I wish to initialize a vector<BYTE> from an existing BYTE array. Simple example: BYTE buf = {0,1,2,3,4,5}; std::vector<BYTE> vec(buf, buf + sizeof(buf)/sizeof(buf));
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.