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(ZipFile zipFile, File destDir)

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

static void extractZip(File zipFile, File destDir)

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

static File extractZipToTemp(File zipFile, String nameHint)

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

Public constructors

ZipUtil2

public ZipUtil2 ()

Public methods

closeZip

public static void closeZip (ZipFile zipFile)

Close an open ZipFile, ignoring any exceptions.

Parameters
zipFile ZipFile: the file to close

extractFileFromZip

public static 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 ERROR(/File) or null if not found

Throws
if failed to extract file

extractZip

public static 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
if failed to extract file

extractZip

public static void extractZip (File zipFile, 
                File destDir)

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

Parameters
zipFile File: a ERROR(/File) pointing to a zip file.

destDir File: the local dir to extract file to

Throws
if failed to extract file

extractZipToTemp

public static 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 ERROR(/File) pointing to the temp directory