9 Aralık 2019 Pazartesi

Compress ZipArchiveInputStream Sınıfı

Giriş
Şu satırı dahil ederiz.
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
constructor - InputStream
Şöyle yaparız
public static List<String> unzipFiles(File zipFile, File targetDirectory) {
  List<String> files = new ArrayList<String>();                       
  try (FileInputStream fileInputStream = new FileInputStream(zipFile);
       ZipArchiveInputStream zipInputStream = new ZipArchiveInputStream(
         new BufferedInputStream(fileInputStream));){                  
        ZipEntry zipEntry;
        while ((zipEntry = zipInputStream.getNextZipEntry()) != null) {
          ...
        }
    } catch (Exception e) {
      e.printStackTrace();
    } 
    return files;
}

Hiç yorum yok:

Yorum Gönder