I used some code snippets below for extracting text from .doc file
HWPFDocument document = new HWPFDocument(new FileInputStream(inputFile));
Range range = document.getRange();
int len = range.numParagraphs();
StringBuilder builder = new StringBuilder();
for (int i = 0; i < len; i++) {
builder.append(range.getParagraph(i).text());
}
and
HWPFDocument document = new HWPFDocument(new FileInputStream(inputFile));
WordExtractor wordExtractor = new WordExtractor(document);
String[] paragraphs = wordExtractor.getParagraphText();
StringBuilder builder = new StringBuilder();
for (String p : paragraphs) {
builder.append(p);
}
However, both of them always output some strange characters. ex: