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();
}
}