public class

ZipBuilder

extends Object
java.lang.Object
   ↳ org.ops4j.pax.exam.spi.war.ZipBuilder

Class Overview

Builds a ZIP archive from individual files and directories.

Summary

Public Constructors
ZipBuilder(File zipFile)
Creates a ZIP archive in the given file.
Public Methods
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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ZipBuilder (File zipFile)

Creates a ZIP archive in the given file. Allocates underlying file system resources. The user must call close() to release these resources.

Throws
IOException

Public Methods

public ZipBuilder addDirectory (File sourceDir, String targetDir)

Recursively adds a directory tree to the archive. The archive must not be closed.

Example:

 sourceDir = /opt/work/classes
 targetDir = WEB-INF/classes
 
 /opt/work/classes/com/acme/Foo.class -> WEB-INF/classes/com/acme/Foo.class
 

Parameters
sourceDir Root directory of tree to be added
targetDir Relative path within the archive corresponding to root. Regardless of the OS, this path must use slashes ('/') as separators.
Returns
  • this for fluent syntax
Throws
IOException

public ZipBuilder addFile (File sourceFile, String targetFile)

Adds a file to the archive. The archive must not be closed.

Example:

 sourceFile = C:\opt\work\deps\foo.jar
 targetDir = WEB-INF/lib/foo.jar
 
 

Parameters
sourceFile File to be added
Returns
  • this for fluent syntax
Throws
IOException

public void close ()

Closes the archive and releases file system resources. No more files or directories may be added after calling this method.

Throws
IOException