byte hex calculation in java -


i amature in byte..hex calculation etc...my application requires me send data through sockets in form of bytes...

1st byte -> [ { ] 2nd byte -> [ { ] 3rd byte  -> [ 0xd1 ] 4th byte -> [ 0x00 ] 5th byte -> [sum of first,second , third hex value] 6th byte -> [ } ] 7th byte -> [ } ] 

this sample how can perform such operation of assigningthe hex values in each byte, storing these bytes in array.. got bit stuck this.. me out ???

you can build array of bytes :

    byte[] data = new byte[7];      data[0] = "{".getbytes()[0];     data[1] = "{".getbytes()[0];     data[2] = (byte) 0xd1;     data[3] = (byte) 0x00;     data[4] = (byte) 0xd1 + 0x00;     data[5] = "}".getbytes()[0];     data[6] = "}".getbytes()[0]; 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -