code: public static String removeNewLines(String textContent) {
      if (textContent == null) {
        return "";
      }
  
      StringBuilder s = new StringBuilder();
      boolean inNl = false;
  
      for (char c : textContent.toCharArray()) {
        if (c == '\n') {
          if (!inNl) {
            s.append(' ');
            inNl = true;
          }
        } else {
          inNl = false;
          s.append(c);
        }
      }
      return s.toString();
    }
docs: Replace multiple newline characters with a single space.
  @param textContent input String