When I want to parse a .docx file, I am doing that :
public String parseDOCX(String fileNameorFilePath )
{
try {
XWPFDocument docx = new XWPFDocument(new FileInputStream(fileNameorFilePath));
XWPFWordExtractor xwpfWordExtractor = new XWPFWordExtractor(docx);
return xwpfWordExtractor.getText();
}
catch ( Exception error )
{
throw new RuntimeException(error);
}
}
When I use this code to parse a .doc file(Word 97-2003) I am getting this exception :
Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13]
What would be the best way to open a .doc file?