Facundo Laxalde
Facundo Laxalde

Reputation: 357

Read password protected .doc file with Java

I have been reading password protected .docx files with org.apache.poi.poifs.filesystem.POIFSFileSystem as follows

FileInputStream fis = new FileInputStream(path)
POIFSFileSystem fs = new POIFSFileSystem(fis)
EncryptionInfo info = new EncryptionInfo(fs);
Decryptor decryptor = Decryptor.getInstance(info);

if (!decryptor.verifyPassword(password)) {
    throw new EncryptedDocumentException("Incorrect password");
    }
InputStream dataStream = decryptor.getDataStream(fs);

This works just fine. Now I need the equivalent for a .doc file. The above code fails since there is no such thing as EncryptionInfo in a .doc file.

Ive explored the following options:

Am I missing something here? reading a .doc file with Java sounds like a very simple thing to do, any ideas ? Thanks!

Upvotes: 0

Views: 38

Answers (0)

Related Questions