question: public int appendBytes ( InputStream in , int max ) throws IOException { max = Math . min ( max , buf . length - ( pos + 2 + 1 ) ) ; int read = 0 , got ; while ( read < max && ( got = in . read ( buf , pos + 2 + read , max - read ) ) > - 1 ) { read += got ; } if ( read > 0 ) { appendInt ( read ) ; pos += read ; appendByte ( 0 ) ; } return read ; }
target:  Utility method to read as many bytes as will fit into the buffer from an InputStream, using the AJPMessage buffer as the read destination. This eliminates an extra buffer, as well as a copy.