ZipUtil2

public class ZipUtil2
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.ZipUtil2


A helper class for zip extraction that takes POSIX file permissions into account

Summary

Public constructors

ZipUtil2()

Public methods

static void closeZip(ZipFile zipFile)

Close an open ZipFile, ignoring any exceptions.

static File extractFileFromZip(ZipFile zipFile, String filePath)

Utility method to extract one specific file from zip file into a tmp file

static void extractZip(File zipFile, File destDir)

Utility method to extract a zip file into a given directory.

static void extractZip(ZipFile zipFile, File destDir)

Utility method to extract entire contents of zip file into given directory

static File extractZipToTemp(File zipFile, String nameHint)

Extract a zip file to a temp directory prepended with a string

Public constructors

ZipUtil2

ZipUtil2 ()

Public methods

closeZip

void closeZip (ZipFile zipFile)

Close an open ZipFile, ignoring any exceptions.

Parameters
zipFile ZipFile: the file to close

extractFileFromZip

File extractFileFromZip (ZipFile zipFile, 
                String filePath)

Utility method to extract one specific file from zip file into a tmp file

Parameters
zipFile ZipFile: the ZipFile to extract

filePath String: the filePath of to extract

Returns
File the File or null if not found

Throws
IOException if failed to extract file

extractZip

void extractZip (File zipFile, 
                File destDir)

Utility method to extract a zip file into a given directory. The zip file being presented as a File.

Parameters
zipFile File: a File pointing to a zip file.

destDir File: the local dir to extract file to

Throws
IOException if failed to extract file

extractZip

void extractZip (ZipFile zipFile, 
                File destDir)

Utility method to extract entire contents of zip file into given directory

Parameters
zipFile ZipFile: the ZipFile to extract

destDir File: the local dir to extract file to

Throws
IOException if failed to extract file

extractZipToTemp

File extractZipToTemp (File zipFile, 
                String nameHint)

Extract a zip file to a temp directory prepended with a string

Parameters
zipFile File: the zip file to extract

nameHint String: a prefix for the temp directory

Returns
File a File pointing to the temp directory

Throws
IOException