I need to delete line breaks in a document docx. My code is this, but it doesn't work with line breaks, only it works with text:
XWPFParagraph toDelete = doc.getParagraphs().stream()
.filter(p-> StringUtils.equalsAnyIgnoreCase("\n", p.getParagraphText()))
.findFirst().orElse(null);
if(toDelete!=null){
doc.removeBodyElement(doc.getPosOfParagraph(toDelete));
}