Last active
December 18, 2015 12:59
-
-
Save zxlooong/5786708 to your computer and use it in GitHub Desktop.
readInnerZipFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean readInnerZipFile(String oriZipFile,String | |
innerZipFileEntryName, String outZipFileEntryName) { | |
ZipFile innerZipFile = null; | |
try { | |
innerZipFile = new ZipFile(oriZipFile); | |
Enumeration entries = innerZipFile.entries(); | |
ZipEntry entryIn = null; | |
while (entries.hasMoreElements()) { | |
ZipEntry entry = entries.nextElement(); | |
// System.out.println(entry); | |
if (entry.getName().compareToIgnoreCase(innerZipFileEntryName) == 0) { | |
entryIn = entry; | |
break; | |
} | |
} | |
if (entryIn != null) { | |
InputStream In = innerZipFile.getInputStream(entryIn); | |
OutputStream ow = new FileOutputStream(outZipFileEntryName,true); | |
byte[] b = new byte[256]; | |
int len = In.read(b); | |
while (len > 0) { | |
ow.write(b, 0, len); | |
len = In.read(b); | |
} | |
ow.flush(); | |
ow.close(); | |
In.close(); | |
return true; | |
} else { | |
return false; | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment