public final class ZipContainer extends Container
Provides a container for zip archives.
Enumerate all files in the archive:
// Create a container for Zip
IContainer container = new ZipContainer(stream);
// Iterate items
for (int i = 0; i < container.getEntities().size(); i++) {
System.out.println("Name: " + container.getEntities().get(i).getName()); // name of the file
System.out.println("Path: " + container.getEntities().get(i).getPath().toString()); // path of the file
System.out.println("MediaType :" + container.getEntities().get(i).getMediaType()); // media type of the file
System.out.println("Date: " + container.getEntities().get(i).getDate().toString()); // date when the file was added to the archive
System.out.println("Size: " + container.getEntities().get(i).getSize()); // uncompressed size of the file
}
Read the concrete file:
// Create a container for ZIP
IContainer container = new ZipContainer(stream);
// Create an extractor for the file
TextExtractor extractor = extractorFactory.createTextExtractor(container.getEntities().get(index).OpenStream());
// Extract a text from the email
System.out.println(extractor == null ? "document isn't supported" : extractor.extractAll());
Container.Entity, Container.EntityParameter
Constructor and Description |
---|
ZipContainer(InputStream stream)
Initializes a new instance of the
ZipContainer class. |
ZipContainer(InputStream stream,
LoadOptions loadOptions)
Initializes a new instance of the
ZipContainer class. |
ZipContainer(String fileName)
Initializes a new instance of the
ZipContainer class. |
ZipContainer(String fileName,
LoadOptions loadOptions)
Initializes a new instance of the
ZipContainer class. |
Modifier and Type | Method and Description |
---|---|
protected void |
dispose(boolean disposing)
Releases the unmanaged resources used by the container.
|
Container.Entity |
getEntity(String name)
Gets an entity by the full entity name.
|
protected List<Container.Entity> |
loadEntities()
Returns a collection of the container's entities.
|
protected InputStream |
openStream(Container.Entity entity)
Returns the stream with the content of the
entity . |
close, dispose, getContainerStream, getEncoding, getEntities, getMediaType, load, openEntityStream, setEncoding, setMediaType
public ZipContainer(String fileName)
Initializes a new instance of the ZipContainer
class.
fileName
- The path to the file.public ZipContainer(String fileName, LoadOptions loadOptions)
Initializes a new instance of the ZipContainer
class.
fileName
- The path to the file.loadOptions
- The options of loading the file.public ZipContainer(InputStream stream)
Initializes a new instance of the ZipContainer
class.
stream
- The stream of the document.public ZipContainer(InputStream stream, LoadOptions loadOptions)
Initializes a new instance of the ZipContainer
class.
stream
- The stream of the document.loadOptions
- The options of loading the file.public Container.Entity getEntity(String name)
Gets an entity by the full entity name.
name
- The entity name.protected void dispose(boolean disposing)
Releases the unmanaged resources used by the container.
protected List<Container.Entity> loadEntities()
Returns a collection of the container's entities.
loadEntities
in class Container
protected InputStream openStream(Container.Entity entity)
Container
Returns the stream with the content of the entity
.
openStream
in class Container
entity
- The entity.java.io.InputStream
with the content of the entity.Copyright © 2018. All rights reserved.