convert zip byte[] to unzip byte[]
You can use ZipInputStream
and ZipOutputStream
(in the package java.util.zip
) to read and write from ZIP files.
If you have the data in a byte array, you can let these read from a ByteArrayInputStream
or write to a ByteArrayOutputStream
pointing to your input and output byte arrays.
public static List<ZipEntry> extractZipEntries(byte[] content) throws IOException {
List<ZipEntry> entries = new ArrayList<>();
ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(content));
ZipEntry entry = null;
while ((entry = zipStream.getNextEntry()) != null)
{
System.out.println( "entry: " + entry );
ZipOutputStream stream= new ZipOutputStream(new FileOutputStream(new File("F:\\ssd\\wer\\"+entry.getName())));
stream.putNextEntry(entry);
}
zipStream.close();
return entries;
}