cdm/src/main/java/ucar/nc2/util/IO.java
static public long copyB(InputStream in, OutputStream out, int bufferSize) throws IOException {
    long totalBytesRead = 0;
    int done = 0, next = 1;

    byte[] buffer = new byte[bufferSize];
    while (true) {
      int n = in.read(buffer);
      if (n == -1) break;
      out.write(buffer, 0, n);
      totalBytesRead += n;

      if (showCopy) {
        done += n;
        if (done > 1000 * 1000 * next) {
          System.out.println(next + " Mb");
          next++;
        }
      }
    }
    out.flush();
    return totalBytesRead;
  }
static public long copyB(InputStream in, OutputStream out, int bufferSize) throws IOException {
    long totalBytesRead = 0;
    int done = 0, next = 1;

    byte[] buffer = new byte[bufferSize];
    while (true) {
      int n = in.read(buffer);
      if (n == -1) break;
      out.write(buffer, 0, n);
      totalBytesRead += n;

      if (showCopy) {
        done += n;
        if (done > 1000 * 1000 * next) {
          System.out.println(next + " Mb");
          next++;
        }
      }
    }
    out.flush();
    return totalBytesRead;
  }
static public long copyB ( InputStream in , OutputStream out , int bufferSize ) throws IOException { long totalBytesRead = 0 ; int done = 0 , next = 1 ; byte [ ] buffer = new byte [ bufferSize ] ; while ( true ) { int n = in . read ( buffer ) ; if ( n == - 1 ) break ; out . write ( buffer , 0 , n ) ; totalBytesRead += n ; if ( showCopy ) { done += n ; if ( done > 1000 * 1000 * next ) { System . out . println ( next + " Mb" ) ; next ++ ; } } } out . flush ( ) ; return totalBytesRead ; }
copy all bytes from in to out, specify buffer size

@param in         InputStream
@param out        OutputStream
@param bufferSize : internal buffer size.
@return number of bytes copied
@throws java.io.IOException on io error
copy all bytes from in to out specify buffer size