开发者

ZipOutputStream relative paths

开发者 https://www.devze.com 2023-02-02 08:01 出处:网络
I create zip file using ZipOutputStream. I put in the zip one file(both file and zip are in the same dir), however开发者_Go百科 the file is stored with fullpath (C:\\TEMP\\file.xml), how to store it w

I create zip file using ZipOutputStream. I put in the zip one file(both file and zip are in the same dir), however开发者_Go百科 the file is stored with fullpath (C:\TEMP\file.xml), how to store it with relative or no path?


You need to set that in the ZipEntry. For example, if you don't want any path, just use the name of the file in your ZipEntry, like this:

    File f = new File("C:\\temp\\file.xml");
    ZipEntry entry = new ZipEntry(f.getName()); 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号