if u look at the code below. I have a byte array and a buffer buf.

the buffer has a length of 3.

i need to add 0x7e before and after the length of the buffer...

lets say if the buffer has 01 01 01 ..it should be sent as 0x7e 01 01 01

so in the code below I am first writing 0x7e

then I am iterating over each element in the buffer and doing some processing
and wring the individual elements...

at the end os iteration I am writing the last 0x7e

hence on the socket I want the out put to be 0x7e 01 01 01 0x7e

but the problem is

first it is writing 0x7e just as 1 byte

and after that it is writing the rest of the 4 bytes 01 01 01 0x7e

thats a problem.....

as it is only when the server gets the info as 0x7e 01 01 01 0x7e it can
understand as a bind request but as it is getting data in two sections i.e
first 0x7e and after that the rest of the 4 bytes...
it is not able to interpret it to be as a bind request and rejecting the
transaction....let me know if you have any solution as to how I should be
writing all the 5 bytes together onto the socket....

is there anyway like loading this into a another byte array and then write
the whole array at once using

os.writeBytes ????

pls let me know