我想在我的 word 文件 (.doc) 中添加密码。我在谷歌搜索它,但只找到(.docx)的解决方案。谁能帮我?我正在使用此代码,但输出文件没有密码。
FileInputStream in = new FileInputStream("Doccc.doc");
BufferedInputStream bin = new BufferedInputStream(in);
POIFSFileSystem poiFileSystem = new POIFSFileSystem(bin);
Biff8EncryptionKey.setCurrentUserPassword("P@ssw0rd");
HWPFDocument doc = new HWPFDocument(poiFileSystem);
Range range = doc.getRange();
FileOutputStream out = new FileOutputStream("Doccc.doc");
doc.write(out);
out.close();