bufr/src/main/java/ucar/nc2/iosp/bufr/writer/BufrSplitter.java
private Buffer readBuffer(InputStream is, Buffer prev, int pos) throws IOException {
    Buffer b = new Buffer();

    // copy remains of last buffer here
    int remain = prev.have - pos;
    //if (remain > BUFFSIZE /2)
    //  out.format(" remain = "+remain+" bytesRead="+bytesRead);

    System.arraycopy(prev.buff, pos, b.buff, 0, remain);
    b.have = remain;


    int want = BUFFSIZE;
    while (b.have < want) {
      int got = is.read(b.buff, b.have, want - b.have);
      if (got < 0) {
        b.done = true;
        break;
      }
      b.have += got;
    }

    if (showRead) System.out.println("Read buffer at " + bytesRead + " len=" + b.have);
    bytesRead += b.have;
    return b;
  }
private Buffer readBuffer(InputStream is, Buffer prev, int pos) throws IOException {
    Buffer b = new Buffer();

    // copy remains of last buffer here
    int remain = prev.have - pos;
    //if (remain > BUFFSIZE /2)
    //  out.format(" remain = "+remain+" bytesRead="+bytesRead);

    System.arraycopy(prev.buff, pos, b.buff, 0, remain);
    b.have = remain;


    int want = BUFFSIZE;
    while (b.have < want) {
      int got = is.read(b.buff, b.have, want - b.have);
      if (got < 0) {
        b.done = true;
        break;
      }
      b.have += got;
    }

    if (showRead) System.out.println("Read buffer at " + bytesRead + " len=" + b.have);
    bytesRead += b.have;
    return b;
  }
private Buffer readBuffer ( InputStream is , Buffer prev , int pos ) throws IOException { Buffer b = new Buffer ( ) ; // copy remains of last buffer here int remain = prev . have - pos ; //if (remain > BUFFSIZE /2) //  out.format(" remain = "+remain+" bytesRead="+bytesRead); System . arraycopy ( prev . buff , pos , b . buff , 0 , remain ) ; b . have = remain ; int want = BUFFSIZE ; while ( b . have < want ) { int got = is . read ( b . buff , b . have , want - b . have ) ; if ( got < 0 ) { b . done = true ; break ; } b . have += got ; } if ( showRead ) System . out . println ( "Read buffer at " + bytesRead + " len=" + b . have ) ; bytesRead += b . have ; return b ; }
read into new Buffer, until buffer is full or end of stream
read into new Buffer until buffer is full or end of stream