POI html 转成word,之后POI读取生成的word 出现数组越界问题

java.lang.ArrayIndexOutOfBoundsException: 98826
at org.apache.poi.util.LittleEndian.getUShort(LittleEndian.java:327)
at org.apache.poi.hwpf.model.FileInformationBlock.(FileInformationBlock.java:113)
at org.apache.poi.hwpf.HWPFDocumentCore.(HWPFDocumentCore.java:167)
at org.apache.poi.hwpf.HWPFDocument.(HWPFDocument.java:197)
at org.apache.poi.hwpf.HWPFDocument.(HWPFDocument.java:181)
at org.apache.poi.hwpf.HWPFDocument.(HWPFDocument.java:169)

贴出你的代码看看呗,光报错不太能看出来吧

没有相关代码不太好判断,不过你可以debug断点调试,多设几个断点,
基本上可以找到有问题的代码行。

html 转成word,之后POI读取生成的word 出现数组越界,具体哪里报出的呢

public class Test {
public static void main(String args[]) throws IOException {
writeWordFile();
File file = new File("E://a.doc");
WordToHtml wordToHtml = new WordToHtml(file);
/*writeWordFile();*/
}

public static boolean writeWordFile() {
    boolean w = false;
    String path = "E:/";
    try {
        if (!"".equals(path)) {
            // 检查目录是否存在
            File fileDir = new File(path);
            if (fileDir.exists()) {
                // 生成临时文件名称
                String fileName = "a.doc";
                File file = new File("D:\\1.html");
                FileInputStream is = new FileInputStream(file);
                InputStreamReader isr = new InputStreamReader(is, "UTF-8");

//将file文件内容转成字符串
BufferedReader bf = new BufferedReader(isr);

                String content = "";
                StringBuilder sb = new StringBuilder();
                while (content != null) {
                    content = bf.readLine();
                    if (content == null) {
                        break;
                    }
                    sb.append(content.trim());
                }
                bf.close();
                content = sb.toString();
                byte b[] = content.getBytes();
                ByteArrayInputStream bais = new ByteArrayInputStream(b);
                POIFSFileSystem poifs = new POIFSFileSystem();
                DirectoryEntry directory = poifs.getRoot();
                DocumentEntry documentEntry = directory.createDocument("WordDocument", bais);
                FileOutputStream ostream = new FileOutputStream(path + fileName);
                poifs.writeFilesystem(ostream);
                poifs.close();
                bais.close();
                ostream.close();
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return w;
}

}


```老哥,你的怎么解决呃,或者有什么其它的方法替代。

估计是文件本身 和文件名 没有对上