How to Detect a File Format and Check if the File is Encrypted
Contents
[
Hide
]
Sometimes you need to detect a file’s format before opening it because the file extension does not guarantee that the file content is appropriate. The file might be encrypted (a password-protected file) so it can’t be read it directly, or we should not read it. Aspose.Cells provides the FileFormatUtil.detectFileFormat() static method and some relevant APIs which you can use to process documents.
Java code to Detect File Format and Check if the File is Encrypted
The following sample code illustrates how to detect a file format (using the file path) and check its extension. You can also determine whether the file is encrypted.