Perry Smith

Java Questions & Answers

Archive

Home / Java Q & A Archive Page 5 / Java Q & A Archive / Java Main Page

Empty the array of bytes
Monday, 26-Jul-1999 03:51:28
202.141.26.2 writes:
I have got an array of bytes, say byte[] dataArray. I perform a read from an InputChannel,say called target ,i.e
int bytesRead = target.read(dataArray,0,100);
Assume that the length of the dataArray is declared to be 100. Now, after reading the data,I want to empty the dataArray.If the data filled is less than 100(the length of the dataArray),the newly added data gets appended,not overwriting the previous data.I want to overwrite the previous data. Kindly help me in this regard.
Thanks in advance
Vidya Shankar

K.S.Vidya Shankar


Response
Re: Empty the array of bytes
Monday, 26-Jul-1999 20:06:44
171.209.224.141 writes:

//why not just instanciate a new byte array


dataArray = new byte[100];
int iBytesRead = target.read(dataArray, 0, 100);
.
.
.
dataArray = new byte[100];
iBytesRead = target.read(dataArray, 0, 100);

MikeD

Home / Java Q & A Archive Page 5 / Java Q & A Archive / Java Main Page