code: private int tailingNonNewline(char[] cbuf, int off, int len) {
      for(int cnt = 0; cnt < len; cnt++) {
        final int pos = off + (len - 1) - cnt;
        if(cbuf[pos] == UNIX_NEWLINE) {
          return cnt;
        }
        if(cbuf[pos] == CARRIAGE_RETURN) {
          return cnt;
        }
        // TODO: need to compare to NEWLINEC, too?
      }
      return len;
    }
docs: Count the tailing non-newline characters.
  
  @param cbuf Character buffer
  @param off Offset
  @param len Range
  @return number of tailing non-newline character