[Solved] How to read doc file using Poi?


You are trying to open a .docx file (XWPF) with code for .doc (HWPF) files. You can use XWPFWordExtractor for .docx files.

There is an ExtractorFactory which you can use to let POI decide which of these applies and uses the correct class to open the file, however you can then not iterate by page as only a generic getText() method is available then.

Use it like this

POITextExtractor extractor = ExtractorFactory.createExtractor(file);
extractor.getText();

3

solved How to read doc file using Poi?