Import java.util.zip. zipoutputstream;
Import java. Io. ioexception;
Import java.util.zip. zipentry;
Import java. Io. fileoutputstream;
Import java. Io. fileinputstream;
Class csvzip {
Public static void zip (string file, string zipfile ){
Try {
// Create a file input stream object
Fileinputstream in = new fileinputstream (File); // 0
// Create a file output stream object
Fileoutputstream out = new fileoutputstream (zipfile); // 1
// Create a zip data output stream object
Zipoutputstream zipout = new zipoutputstream (out );
// Create an entry pointing to the compressed original file
Zipentry entry = new zipentry (File); // 0
Zipout. putnextentry (entry );
// Output data to the compressed file
Int nNumber;
Byte [] buffer = new byte [512];
While (nNumber = in. Read (buffer ))! =-1)
Zipout. Write (buffer, 0, nNumber );
// Close the created Stream Object
Zipout. Close ();
Out. Close ();
In. Close ();
} Catch (ioexception e ){
System. Out. println (E );
}
}
}