0

希望获取现有文件(xml)并将其放在 zip 目录中。我遇到的问题是xml文件当前所在的目录也写入了zip。有人对此有想法吗?

  byte[] buffer = new byte[1024];

            FileOutputStream fos = new FileOutputStream(loc + "/dir" + endFileExt+".kmz");
            ZipOutputStream zos = new ZipOutputStream(fos);

            ZipEntry ze = new ZipEntry(loc + "/dir" + endFileExt+".xml");
            zos.putNextEntry(ze);
            FileInputStream in = new FileInputStream(loc + "/dir" + endFileExt+".xml");
            int len;
            while ((len = in .read(buffer)) > 0) {
                zos.write(buffer, 0, len);
            }

            in.close();
            zos.closeEntry();
            zos.close();
4

0 回答 0