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
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.