ファイルフォーマットを検出してファイルが暗号化されているかどうかをチェックする方法

Javaコードでファイル形式を検出し、ファイルが暗号化されているかどうかをチェックする

次のサンプルコードは、ファイルパスを使用してファイルの形式を検出し、その拡張子をチェックし、ファイルが暗号化されているかどうかを判断する方法を示しています。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(DetectFileFormatandCheckFileEncrypted.class);
// Detect file format
FileFormatInfo info = FileFormatUtil.detectFileFormat(dataDir + "Book1.xlsx");
// Gets the detected load format
System.out.println("The spreadsheet format is: " + FileFormatUtil.loadFormatToExtension(info.getLoadFormat()));
// Check if the file is encrypted.
System.out.println("The file is encrypted: " + info.isEncrypted());