/**
* zip压缩功能.
* 压缩baseDir(文件夹目录)下所有文件,包括子目录
* @throws Exception
*/
private static void zipFile(File file, String filePath) throws Exception{
//压缩文件
File tf = new File(filePath.replace(".txt", ".zip"));
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tf));
zos.putNextEntry(new ZipEntry(file.getName()));
byte[] buf=new byte[1024];
int readLen=0;
InputStream is=new BufferedInputStream(new FileInputStream(file));
while ((readLen=is.read(buf, 0, 1024))!=-1) {
zos.write(buf, 0, readLen);
}
is.close();
zos.close();
}