Sunday, January 13, 2013

Write Zip file using Java code

1:10 AM


THIS IS A SIMPLE CODE TO WRITE A ZIP FILE ........


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

public class Main {
  public static void main(String[] argsthrows 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();
  }
}

Written by

We are one of the initiators of the development of information technology in understanding the need for a solution that is familiar and close to us.

0 comments:

Post a Comment

 

© 2013 Klick Dev. All rights resevered.

Back To Top