[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Appending Bytes To A Byte Array



Not sure how you'd re-dim the array; however, a simple way is to create a new array of desired size, use System.arraycopy(Array src, int src_position, Array dst, int dst_position, int n) to populate new array; and reset the array reference of the old array to the new array - oldArray = newArray;
 
Hope this helps.
-----Original Message-----
From: Gregory A. Lusk [mailto:glusk@mesasub.com]
Sent: Thursday, December 19, 2002 5:58 PM
To: ajug-members@www.ajug.org
Subject: Appending Bytes To A Byte Array

I'm sure there is an easy way to do this:

 

I am trying to define a method that accepts a byte array as input and appends 3 bytes to it (little endian) - just a simple encoding process. What is the preferred way to do this?  I thought about just re-dimensioning the size of the array to include the three new bytes, left shifting the array by three bytes, then setting the values.  Is there an easier way?

 

Thanks,

 

Greg Lusk