I thought that wasn\'t that hard to do, but I want to remove all empty lines (or lines just containing blanks and tabs in Java) with String.replaceAll.
My regex look
You can remove empty lines from your code using the following code:
String test = plainTextWithEmptyLines.replaceAll("[\\\r\\\n]+","");
Here, plainTextWithEmptyLines denotes the string having the empty lines. [\\\r\\\n] is the regex pattern which is used to identify empty line breaks.
plainTextWithEmptyLines
[\\\r\\\n]