Apache POI加密.doc文件无法在Word中打开

问题描述 投票:0回答:0

当我加密一个简单的文档文件时。像这样enter image description here

可以在Microsoft Word中打开。当我像这样更改另一个复杂的文档文件时 enter image description here

无法在 Microsoft Word 中打开。我不知道为什么。

public static boolean encrypDOC(String sourceFilePath, OutputStream out, String password) throws IOException {
        POIFSFileSystem fs = null;
        HWPFDocument doc = null;
        try {
            fs = new POIFSFileSystem(new FileInputStream(sourceFilePath));
            doc = new HWPFDocument(fs);
            Biff8EncryptionKey.setCurrentUserPassword(password);
            doc.write(out);
            return true;
        } catch (Exception e) {
            return false;
        } finally {
            doc.close();
            fs.close();
            out.close();
        }
}
encryption apache-poi doc
© www.soinside.com 2019 - 2024. All rights reserved.