nl_tokens: Visible for testing
pl_tokens: static int readDirectBuffer ( InputStream f , ByteBuffer buf , byte [ ] temp ) throws IOException { // copy all the bytes that return immediately, stopping at the first // read that doesn't return a full buffer. int nextReadLength = Math . <mask> ( buf . remaining ( ) , temp . length ) ; int totalBytesRead = 0 ; int bytesRead ; while ( ( bytesRead = f . read ( temp , 0 , nextReadLength ) ) == temp . length ) { buf . put ( temp ) ; totalBytesRead += bytesRead ; nextReadLength = Math . min ( buf . remaining ( ) , temp . length ) ; } if ( bytesRead < 0 ) { // return -1 if nothing was read return totalBytesRead == 0 ? - 1 : totalBytesRead ; } else { // copy the last partial buffer buf . put ( temp , 0 , bytesRead ) ; totalBytesRead += bytesRead ; return totalBytesRead ; } }