Java poi word read

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


Mar.02,2021

indicates that the initial file does not quite conform to the word document specification. Save after opening it with word is sure to meet the specification


has the boss solved it?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36db6-4ecb0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36db6-4ecb0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?