The following example shows how to detect a file type of container items:
// Create an instance of Parser classtry(Parserparser=newParser(Constants.SampleZip)){// Extract attachments from the containerIterable<ContainerItem>attachments=parser.getContainer();// Check if container extraction is supportedif(attachments==null){System.out.println("Container extraction isn't supported");}// Iterate over attachmentsfor(ContainerItemitem:attachments){// Detect the file typeFileTypefileType=item.detectFileType(FileTypeDetectionMode.Default);// Print the name and file typeSystem.out.println(String.format("%s: %s",item.getName(),fileType));}}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples: