Package com.itextpdf.commons.utils
Class ZipFileWriter
java.lang.Object
com.itextpdf.commons.utils.ZipFileWriter
- All Implemented Interfaces:
-
Closeable
,AutoCloseable
Allows writing entries into a zip file.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add file from disk into zip archive.void
addEntry
(String fileName, InputStream inputStream) Add file into zip archive with data from stream.void
addJsonEntry
(String fileName, Object objectToAdd) Add file into zip archive with object serialized as JSON.void
close()
-
Constructor Details
-
ZipFileWriter
Creates an instance for zip file writing.- Parameters:
-
archivePath
- the path to the zip file to write - Throws:
-
IOException
- if some I/O exception occurs
-
-
Method Details
-
addEntry
Add file from disk into zip archive.- Parameters:
-
fileName
- the target name of the file inside zip after writing -
file
- the path to the file on disk to archive - Throws:
-
IOException
- if some I/O exception occurs
-
addEntry
Add file into zip archive with data from stream.- Parameters:
-
fileName
- the target name of the file inside zip after writing -
inputStream
- the input stream to archive - Throws:
-
IOException
- if some I/O exception occurs
-
addJsonEntry
Add file into zip archive with object serialized as JSON.- Parameters:
-
fileName
- the target name of the file inside zip after writing -
objectToAdd
- the object to serialize as JSON - Throws:
-
IOException
- if some I/O exception occurs
-
close
- Specified by:
-
close
in interfaceAutoCloseable
- Specified by:
-
close
in interfaceCloseable
- Throws:
-
IOException
-