ZipOutputStream: closeEntry() : ZipOutputStream « java.util.zip « Java by API






ZipOutputStream: closeEntry()

 
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class Main {
  public static void main(String[] args) throws Exception {
    FileOutputStream fos = new FileOutputStream("C:/MyZip.zip");
    ZipOutputStream zos = new ZipOutputStream(fos);
    ZipEntry ze = new ZipEntry("C:/file1.txt");
    zos.putNextEntry(ze);
    zos.closeEntry();
    ze = new ZipEntry("C:/file2.txt");
    zos.putNextEntry(ze);
    zos.closeEntry();
    zos.close();
  }
}

   
  








Related examples in the same category

1.new ZipOutputStream(OutputStream out)
2.ZipOutputStream: close()
3.ZipOutputStream: putNextEntry(ZipEntry e)
4.ZipOutputStream: setComment(String comment)