Server side: public void transfer(DataOutputStream output) { try{ int i = 0; int auglis = 50058; //chunk size //if it is wav file, we need to edit header: //audio[4] = (byte)0x8A; // audio[5] = (byte)0xC3; // audio[6] = (byte)0x00; // audio[7] = (byte)0x00; // audio[54] = (byte)0x50; // audio[55] = (byte)0xC3; // audio[56] = (byte)0x00; // audio[57] = (byte)0x00; byte[] tmp = new byte[50058]; int countBytes= 0; int headerup = 32; //mp3 header is 32 bytes. while(i<50058){ tmp[i] = audio[i]; //byte array audio is byte array from mp3 file i++; countBytes++; } output.writeInt(50058); //write to midlet, that chunk size will be 50058 output.write(tmp); //write chunk itself boolean varam = true; //booleand that will become false, when file ends while(varam){ int tmplen = garums - countBytes; //check if it is not last chunk int o=50058; if(tmplen>50058){ //if it is not last chunk o = 50058; } else{ o = tmplen+headerup; // if it is last chunk tmp = new byte[o]; varam = false; //out while loop will end } int z = 0; while(z<32){ //write 32 byte header to chunk tmp[z] = audio[z]; z++; countBytes++; } while(z