Sailendra Narayan Jena |
package com.lara;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class CreateZipFile
{
public static void main(String[] args)
{
byte[] buffer = new byte[1024];
try
{
FileOutputStream fout = new FileOutputStream("D:\\Mukesh Snaps At Waynad\\Waynad Scenarious\\20130330_114047.zip");
ZipOutputStream zout = new ZipOutputStream(fout);
ZipEntry entry = new ZipEntry("20130330_114047.jpg");
zout.putNextEntry(entry);
FileInputStream fin = new FileInputStream("D:\\Mukesh Snaps At Waynad\\Waynad Scenarious\\20130330_114047.jpg");
int length;
while((length = fin.read(buffer))>0)
{
zout.write(buffer, 0, length);
}
fin.close();
zout.closeEntry();
zout.close();
System.out.println("Done");
}
catch(IOException ex)
{
ex.printStackTrace();
}
}
}
No comments:
Post a Comment