public class ZipFileWriter extends Object implements Closeable
Constructor and Description |
---|
ZipFileWriter(String archivePath)
Creates an instance for zip file writing.
|
Modifier and Type | Method and Description |
---|---|
void |
addEntry(String fileName, File file)
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() |
public ZipFileWriter(String archivePath) throws IOException
archivePath
- the path to the zip file to write
IOException
- if some I/O exception occurs
public void addEntry(String fileName, File file) throws IOException
fileName
- the target name of the file inside zip after writing
file
- the path to the file on disk to archive
IOException
- if some I/O exception occurs
public void addEntry(String fileName, InputStream inputStream) throws IOException
fileName
- the target name of the file inside zip after writing
inputStream
- the input stream to archive
IOException
- if some I/O exception occurs
public void addJsonEntry(String fileName, Object objectToAdd) throws IOException
fileName
- the target name of the file inside zip after writing
objectToAdd
- the object to serialize as JSON
IOException
- if some I/O exception occurs
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 1998–2022 iText Group NV. All rights reserved.