Package com.itextpdf.commons.utils
Class ZipFileWriter
- java.lang.Object
-
- com.itextpdf.commons.utils.ZipFileWriter
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class ZipFileWriter extends java.lang.Object implements java.io.CloseableAllows writing entries into a zip file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static interfaceZipFileWriter.ZipWriter
-
Field Summary
Fields Modifier and Type Field Description private java.util.zip.ZipOutputStreamoutputStream
-
Constructor Summary
Constructors Constructor Description ZipFileWriter(java.lang.String archivePath)Creates an instance for zip file writing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEntry(java.lang.String fileName, java.io.File file)Add file from disk into zip archive.voidaddEntry(java.lang.String fileName, java.io.InputStream inputStream)Add file into zip archive with data from stream.private voidaddEntryToZip(java.lang.String fileName, ZipFileWriter.ZipWriter writer)voidaddJsonEntry(java.lang.String fileName, java.lang.Object objectToAdd)Add file into zip archive with object serialized as JSON.voidclose()
-
-
-
Method Detail
-
addEntry
public void addEntry(java.lang.String fileName, java.io.File file) throws java.io.IOExceptionAdd file from disk into zip archive.- Parameters:
fileName- the target name of the file inside zip after writingfile- the path to the file on disk to archive- Throws:
java.io.IOException- if some I/O exception occurs
-
addEntry
public void addEntry(java.lang.String fileName, java.io.InputStream inputStream) throws java.io.IOExceptionAdd file into zip archive with data from stream.- Parameters:
fileName- the target name of the file inside zip after writinginputStream- the input stream to archive- Throws:
java.io.IOException- if some I/O exception occurs
-
addJsonEntry
public void addJsonEntry(java.lang.String fileName, java.lang.Object objectToAdd) throws java.io.IOExceptionAdd file into zip archive with object serialized as JSON.- Parameters:
fileName- the target name of the file inside zip after writingobjectToAdd- the object to serialize as JSON- Throws:
java.io.IOException- if some I/O exception occurs
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
addEntryToZip
private void addEntryToZip(java.lang.String fileName, ZipFileWriter.ZipWriter writer) throws java.io.IOException- Throws:
java.io.IOException
-
-