public class ZipBuilder extends Object
| Constructor and Description |
|---|
ZipBuilder(File zipFile)
Creates a ZIP archive in the given file.
|
| Modifier and Type | Method and Description |
|---|---|
ZipBuilder |
addDirectory(File sourceDir,
String targetDir)
Recursively adds a directory tree to the archive.
|
ZipBuilder |
addFile(File sourceFile,
String targetFile)
Adds a file to the archive.
|
void |
close()
Closes the archive and releases file system resources.
|
public ZipBuilder(File zipFile) throws IOException
close() to release these resources.zipFile - archive file to be createdIOException - on I/O errorpublic ZipBuilder addDirectory(File sourceDir, String targetDir) throws IOException
Example:
sourceDir = /opt/work/classes targetDir = WEB-INF/classes /opt/work/classes/com/acme/Foo.class -> WEB-INF/classes/com/acme/Foo.class
sourceDir - Root directory of tree to be addedtargetDir - Relative path within the archive corresponding to root. Regardless of the OS, this
path must use slashes ('/') as separators.IOException - on I/O errorpublic ZipBuilder addFile(File sourceFile, String targetFile) throws IOException
Example:
sourceFile = C:\opt\work\deps\foo.jar targetDir = WEB-INF/lib/foo.jar
sourceFile - File to be addedtargetFile - Relative path for the file within the archive. Regardless of the OS, this path
must use slashes ('/') as separators.IOException - on I/O errorpublic void close()
throws IOException
IOException - on I/O errorCopyright © 2006–2017 OPS4J - Open Participation Software for Java. All rights reserved.