@NotThreadSafe public class ZipArchiver extends Object
Constructor and Description |
---|
ZipArchiver(File archiveFile) |
Modifier and Type | Method and Description |
---|---|
void |
addEntry(InputStream content,
String entryPath)
Adds new entry to zip archive with name specified by
entryPath parameter and with content from provided
InputStream |
void |
addFile(File sourceFile,
String targetPath)
Adds a file to archive.
|
void |
addFolder(File folderToCompress,
ArchiveParams archiveParams)
Adds directory and all subdirectories into archive.
|
void |
addFolder(File folderToCompress,
String archiveFolderName)
Adds directory and all subdirectories into archive.
|
OutputStream |
addNextEntry(String entryName)
Creates new zipEntry and provides OutputStream to write content to given entry.
|
void |
close() |
public ZipArchiver(File archiveFile)
public void addFolder(File folderToCompress, String archiveFolderName) throws IOException
folderToCompress
- the directory handle to add to archivearchiveFolderName
- the name which will be used as archive directory name, for example when folderToCompress
is pointing into /home/A/B directory which contains file with path
/home/A/B/C/file and archiveFolderName
equals "archive" a result zip archive
will contain entry: /archive/C/fileIOException
public void addFolder(File folderToCompress, ArchiveParams archiveParams) throws IOException
folderToCompress
- the directory handle to add to archivearchiveParams
- parameters for the files in the folder to be added the to archiveIOException
public void addFile(File sourceFile, String targetPath) throws IOException
sourceFile
- a file which content will be added as new entrytargetPath
- a file path which will be used as entry nameIOException
public void addEntry(InputStream content, String entryPath) throws IOException
entryPath
parameter and with content from provided
InputStream
content
- stream which will be used as entry contententryPath
- will be used as entry nameIOException
public OutputStream addNextEntry(String entryName) throws IOException
entryName
- the name of zip entryIOException
public void close() throws IOException
IOException
Copyright © 2003–2017 Atlassian. All rights reserved.