byte[] buffer = new byte[1000]; while (inputStream.available() > 0) //as long as there are unread bytes { //Read the next block of bytes into buffer, and store the actual number of bytes read in count. int count =; outputStream.write(buffer, 0, count/2); outputStream1.write(buffer, (count-1)/2, count);}//Write a block (part of a block) to the second stream inputStream.close(); //Close both streams. We don't need them any more. outputStream.close(); outputStream1.close(); }