public void getZipFiles(String zipFile, String destFolder) throws IOException {
BufferedOutputStream dest = null
ZipInputStream zis = new ZipInputStream(
new BufferedInputStream(
new FileInputStream(zipFile)))
ZipEntry entry
while (( entry = zis.getNextEntry() ) != null) {
System.out.println( "Extracting: " + entry.getName() )
int count
byte data[] = new byte[BUFFER]
if (entry.isDirectory()) {
new File( destFolder + "/" + entry.getName() ).mkdirs()
continue
} else {
int di = entry.getName().lastIndexOf( '/' )
if (di != -1) {
new File( destFolder + "/" + entry.getName()
.substring( 0, di ) ).mkdirs()
}
}
FileOutputStream fos = new FileOutputStream( destFolder + "/"
+ entry.getName() )
dest = new BufferedOutputStream( fos )
while (( count = zis.read( data ) ) != -1)
dest.write( data, 0, count )
dest.flush()
dest.close()
}
}
rar的只能用第三方api,比如junrar
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)