code: private void filterCR(boolean moreData) {
          int i, j;
  
          readBufferOverflow = -1;
  
          loop: for (i = j = readBufferPos; j < readBufferLength; i++, j++) {
              switch (readBuffer[j]) {
                  case '\r':
                      if (j == readBufferLength - 1) {
                          if (moreData) {
                              readBufferOverflow = '\r';
                              readBufferLength--;
                          } else // CR at end of buffer
                          {
                              readBuffer[i++] = '\n';
                          }
                          break loop;
                      } else if (readBuffer[j + 1] == '\n') {
                          j++;
                      }
                      readBuffer[i] = '\n';
                      break;
  
                  case '\n':
                  default:
                      readBuffer[i] = readBuffer[j];
                      break;
              }
          }
          readBufferLength = i;
      }
docs: Filter carriage returns in the read buffer. CRLF becomes LF; CR becomes
  LF.
  
  @param moreData
  true iff more data might come from the same source
  @see #readDataChunk
  @see #readBuffer
  @see #readBufferOverflow