/**
* 解压zip文件到指定的xml文件
*
* @param zipFileName
* 文件名及目录
* @param outputDirectory
* 解压到的目录
*/
private void unzip(final String zipFileName, final String outputDirectory) {
ZipInputStream mIn = null;
try {
mIn = new ZipInputStream(new FileInputStream(zipFileName));
ZipEntry mZip;
String mFileName = "";
String mExtractedFile = "";
int mCounter = 0;
while ((mZip = mIn.getNextEntry()) != null) {
mFileName = mZip.getName();
if (mZip.isDirectory()) {
mFileName = mFileName.substring(0, mFileName.length() - 1);
File folder = new File(outputDirectory + File.separator
+ mFileName);
folder.mkdirs();
if (mCounter == 0) {
mExtractedFile = folder.toString();
}
mCounter++;
} else {
File mFile = new File(outputDirectory + File.separator
+ mFileName);
mFile.createNewFile();
FileOutputStream mOut = new FileOutputStream(mFile);
int ch;
byte[] buffer = new byte[1024];
while ((ch = mIn.read(buffer)) != -1) {
mOut.write(buffer, 0, ch);
mOut.flush();
}
mOut.close();
}
}
mIn.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}