How to Detect a File Format and Check if the File is Encrypted

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.