Check if collection isn’t null (container extraction is supported for the document);
Iterate through the collection and get container item names, sizes and obtain content.
The following example shows how to extract attachments from a container:
// Create an instance of Parser class
try(Parserparser=newParser(Constants.SampleZip)){// Extract attachments from the container
Iterable<ContainerItem>attachments=parser.getContainer();// Check if container extraction is supported
if(attachments==null){System.out.println("Container extraction isn't supported");}// Iterate over attachments
for(ContainerItemitem:attachments){// Print an item name and size
System.out.println(String.format("%s: &s",item.getName(),item.getSize()));}}
Container represents both container-only files (like zip archives, outlook storage) and documents with attachments (like emails, PDF Portfolios).
In case of outlook storage (ost/pst files) container consists of email documents (msg files).
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples: