if((inputStream != null) && (outputStream != null)) { OutputStream os = (outputStream instanceof BufferedOutputStream) ? outputStream : new BufferedOutputStream(outputStream); int nextByte = inputStream.read(); while(nextByte != -1) { os.write(nextByte); nextByte = inputStream.read(); } os.flush(); inputStream.close(); }
int bytesRead; byte[] buffer = new byte[2048]; while ((bytesRead = inputStream.read(buffer)) > 0) { outputStream.write(buffer, 0, bytesRead); } inputStream.close();
   public static void write(InputStream inputStream, OutputStream outputStream) throws IOException   {   	if((inputStream != null) && (outputStream != null))   	{	      OutputStream os = (outputStream instanceof BufferedOutputStream) ? outputStream : new BufferedOutputStream(outputStream);	      int nextByte = inputStream.read();	      while(nextByte != -1)	      {	         os.write(nextByte);	         nextByte = inputStream.read();	      }	      os.flush();	      inputStream.close();   	}   }