Package pl.wrzasq.lambda.edgedeploy.zip
Class ZipBuilder
- java.lang.Object
-
- pl.wrzasq.lambda.edgedeploy.zip.ZipBuilder
-
public class ZipBuilder extends Object
Utility class for building ZIP archive stream.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static interface
ZipBuilder.ContentWriter
Internal interface for writing operations.
-
Field Summary
Fields Modifier and Type Field Description private static int
BUFFER_SIZE
Size of bytes buffer for resource processing.private ByteArrayOutputStream
output
Output stream.private ZipOutputStream
zip
ZIP compression stream.
-
Constructor Summary
Constructors Constructor Description ZipBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
copyFrom(ZipInputStream archive)
Copies another archive into current one.ByteBuffer
dump()
Closes active stream.void
writeEntry(String name, byte[] content)
Creates new ZIP archive entry.void
writeEntry(String name, InputStream stream)
Creates new ZIP archive entry.private void
writeEntry(String name, ZipBuilder.ContentWriter handler)
Creates ZIP entry.
-
-
-
Field Detail
-
BUFFER_SIZE
private static final int BUFFER_SIZE
Size of bytes buffer for resource processing.- See Also:
- Constant Field Values
-
output
private ByteArrayOutputStream output
Output stream.
-
zip
private ZipOutputStream zip
ZIP compression stream.
-
-
Method Detail
-
writeEntry
public void writeEntry(String name, byte[] content) throws IOException
Creates new ZIP archive entry.- Parameters:
name
- Entry stackSetName.content
- Binary content of the file.- Throws:
IOException
- When writing content to archive fails.
-
writeEntry
public void writeEntry(String name, InputStream stream) throws IOException
Creates new ZIP archive entry.- Parameters:
name
- Entry stackSetName.stream
- Content source.- Throws:
IOException
- When writing content to archive fails.
-
writeEntry
private void writeEntry(String name, ZipBuilder.ContentWriter handler) throws IOException
Creates ZIP entry.- Parameters:
name
- Entry stackSetName.handler
- Custom writing logic.- Throws:
IOException
- When writing to stream fails.
-
copyFrom
public void copyFrom(ZipInputStream archive) throws IOException
Copies another archive into current one.- Parameters:
archive
- Source.- Throws:
IOException
- When reading source archive fails.
-
dump
public ByteBuffer dump() throws IOException
Closes active stream.- Returns:
- Archive binary content.
- Throws:
IOException
- When dumping ZIP stream fails.
-
-