code: private String stripLineBreaks(String text, String replacement)
     {
        if (text.indexOf('\r') != -1 || text.indexOf('\n') != -1)
        {
           StringBuilder sb = new StringBuilder(text);
  
           int index;
  
           while ((index = sb.indexOf("\r\n")) != -1)
           {
              sb.replace(index, index + 2, replacement);
           }
  
           while ((index = sb.indexOf("\n\r")) != -1)
           {
              sb.replace(index, index + 2, replacement);
           }
  
           while ((index = sb.indexOf("\r")) != -1)
           {
              sb.replace(index, index + 1, replacement);
           }
  
           while ((index = sb.indexOf("\n")) != -1)
           {
              sb.replace(index, index + 1, replacement);
           }
  
           text = sb.toString();
        }
  
        return (text);
     }
docs: This method removes line breaks from a piece of text, and replaces
  them with the supplied text.
  
  @param text source text
  @param replacement line break replacement text
  @return text with line breaks removed.