我想为我的word文件(.doc)添加密码。我在谷歌搜索它,但只找到(.docx)的解决方案。谁能帮我?我正在使用此代码,但输出文件没有密码。添加带密码apache poi的word(.doc)文件
FileInputStream in = new FileInputStream("Doccc.doc");
BufferedInputStream bin = new BufferedInputStream(in);
POIFSFileSystem poiFileSystem = new POIFSFileSystem(bin);
Biff8EncryptionKey.setCurrentUserPassword("[email protected]");
HWPFDocument doc = new HWPFDocument(poiFileSystem);
Range range = doc.getRange();
FileOutputStream out = new FileOutputStream("Doccc.doc");
doc.write(out);
out.close();
你看过[Apache POI支持的加密/密码保护矩阵](http://poi.apache.org/encryption.html)吗? – Gagravarr
@Gagravarr是的。在该指南中不支持.doc文件,它只支持.docx文件。任何人都可以提出另一种方式? – kids