code: public static void copyStream(InputStream copyFrom, OutputStream copyTo,
  			GeoPackageProgress progress) throws IOException {
  
  		try {
  			byte[] buffer = new byte[1024];
  			int length;
  			while ((progress == null || progress.isActive())
  					&& (length = copyFrom.read(buffer)) > 0) {
  				copyTo.write(buffer, 0, length);
  				if (progress != null) {
  					progress.addProgress(length);
  				}
  			}
  
  			copyTo.flush();
  		} finally {
  			closeQuietly(copyTo);
  			closeQuietly(copyFrom);
  		}
  
  	}
docs: Copy an input stream to an output stream
  
  @param copyFrom
  from stream
  @param copyTo
  to stream
  @param progress
  progress tracker
  @throws IOException
  upon failure