Thanks Rob for your reply ,
Use DataOutputStream to write, DataInputStream to read. That way, you can use writeInt to first write the number of bytes, then write that many bytes.
You mean writing in the client side , by the way the client machine is a device manufactured by third party and so i can not do anything from client side .
All the code will be At server side . nothing to be done at the client side.