use poi to read word files.
always report errors
org.apache.poi.poifs.filesystem.NotOLE2FileException: Invalid header signature; read 0xC9D33C3A6D6F7246, expected 0xE11AB1A1E011CFD0-Your file appears not to be a valid OLE2 document
public static void readAndWriterTest3() throws IOException {
File file = new File("D:\\jl\\2.doc");
String str = "";
try {
FileInputStream fis = new FileInputStream(file);
HWPFDocument doc = new HWPFDocument(fis);
String doc1 = doc.getDocumentText();
System.out.println(doc1);
StringBuilder doc2 = doc.getText();
System.out.println(doc2);
Range rang = doc.getRange();
String doc3 = rang.text();
System.out.println(doc3);
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
wordwordpoi