Here you can find the source of decompressFolderByteArray(byte[] folderAsCompressedArray, File unzippedLocation)
Parameter | Description |
---|---|
folderAsCompressedArray | to decompress |
unzippedLocation | where the decompressed folder should be |
Parameter | Description |
---|---|
IOException | e |
FileNotFoundException | e |
public static void decompressFolderByteArray(byte[] folderAsCompressedArray, File unzippedLocation) throws IOException, FileNotFoundException
//package com.java2s; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { /**/*from w ww . ja v a2 s.c o m*/ * Decompresses a given byte array that is a compressed folder. * * @param folderAsCompressedArray to decompress * @param unzippedLocation where the decompressed folder should be * @throws IOException e * @throws FileNotFoundException e */ public static void decompressFolderByteArray(byte[] folderAsCompressedArray, File unzippedLocation) throws IOException, FileNotFoundException { ZipInputStream zipFile = new ZipInputStream(new ByteArrayInputStream(folderAsCompressedArray)); ZipEntry ze = null; final int minusOne = -1; while ((ze = zipFile.getNextEntry()) != null) { FileOutputStream fout = new FileOutputStream( new File(unzippedLocation, ze.getName()).getAbsolutePath()); for (int c = zipFile.read(); c != minusOne; c = zipFile.read()) { fout.write(c); } zipFile.closeEntry(); fout.close(); } zipFile.close(); } }