我正在生成pcap文件,需要压缩它。目前我能够在本地存储中生成并存储pcap文件。
对于压缩我使用下面的代码:
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(String... urls) {
byte[] buffer = new byte[1024];
try {
zipFilePath = urls[0];
FileOutputStream fos = new FileOutputStream(zipFilePath + ".zip");
ZipOutputStream zos = new ZipOutputStream(fos);
ZipEntry ze = new ZipEntry(urls[1]);
zos.putNextEntry(ze);
FileInputStream in = new FileInputStream(zipFilePath);
int len;
while ((len = in.read(buffer)) > 0) {
zos.write(buffer, 0, len);
}
in.close();
zos.closeEntry();
//remember close it
zos.close();
return zipFilePath + ".zip";
} catch (IOException ex) {
ex.printStackTrace();
return "";
}
}
我在file not found
FileOutputStream fos = new FileOutputStream(zipFilePath + ".zip");
例外