If the newline(s) are on the end, the normal trim() will remove whitespace, including line feeds and tabs. If they are in the middle you can use String.replace("\n", " ") to convert them to blanks, which avoids running words together that used to be on different lines. See if either of those do what you need.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
a bit of art, as a gift, that will fit in a stocking