17 Aralık 2020 Perşembe

Compress ZipFile Sınıfı

Giriş
Şu satırı dahil ederiz.
import org.apache.commons.compress.archivers.zip.ZipFile;
constructor - File
Şöyle yaparız
ZipFile z = new ZipFile(zippath);
Enumeration<ZipArchiveEntry> entries = z.getEntries();

while(entries.hasMoreElements()) {
  ZipArchiveEntry entry = entries.nextElement();
  System.out.println("Entry: "+entry.getName());
  BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream(unzipfolder+"\\"+entry.getName())); BufferedInputStream bis = new BufferedInputStream(z.getInputStream(entry)); byte[] buffer=new byte[1000000]; int len=0; while((len=bis.read(buffer,0,1000000))>0) { bos.write(buffer, 0, len) ; } bis.close(); bos.close(); }

Hiç yorum yok:

Yorum Gönder