有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

压缩Pcap文件中的java问题

我正在生成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 "";
    }
}

我在FileOutputStream fos = new FileOutputStream(zipFilePath + ".zip");得到file not found异常


共 (0) 个答案