6.2

Table Of Contents
Sample String Property Script Syntax Sample Usage
Windows
PowerShell -
$HQ_PACKAGE
& c:\unzip.exe
$HQ_PACKAGE
BeanShell -
HQ_PACKAGE
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
destDir = new File(bsh.cwd);
if (!destDir.exists()) {
destDir.mkdir();
}
zipIn = new
ZipInputStream(new
FileInputStream(HQ_PACKAGE));
entry =
zipIn.getNextEntry();
// iterates over entries in
the zip file
while (entry != null) {
String filePath =
bsh.cwd + File.separator +
entry.getName();
if (!
entry.isDirectory()) {
// if the entry is
a file, extracts it
bos = new
BufferedOutputStream(new
FileOutputStream(filePath));
bytesIn = new
byte[4096];
read = 0;
while ((read =
zipIn.read(bytesIn)) != -1) {
bos.write(bytesIn, 0, read);
}
bos.close();
} else {
// if the entry is
a directory, make the directory
dir = new
File(filePath);
dir.mkdir();
}
zipIn.closeEntry();
entry =
zipIn.getNextEntry();
}
zipIn.close();
Using Application Services
VMware, Inc. 106