Verify file password protection using Aspose.Slides for Java

How can i check whether a file(.docx, .rtf, .pdf,.xls, .xlsx etc) is password protected or not?
Can i get the java sample code?


I have observed your comments. For Aspose.Cells, please visit this documentation link to achieve your requirements. We will update you for Aspose.PDF and Aspose.Words soon.

Can I also get sample code for ppt and pptx files?


For Aspose.Slides, you need to load the password protected presentation and InvalidPasswordException is thrown upon loading a password protected presentation. You can then load the presentation in catch block using following code.

public static void TestLoadPassProtected()
        Presentation pres = new Presentation("C:\\Aspose Data\\PassPres.pptx");
    catch (InvalidPasswordException e)
        LoadOptions options = new LoadOptions();
        options.setPassword ("abc");
        Presentation pres = new Presentation("C:\\Aspose Data\\PassPres.pptx",options);
        boolean isEncrypted= pres.getProtectionManager().isEncrypted();

In order to verify the protected PDF, I suggest you to please visit this documentation link on your end.