IAdapter
IAdapter

Reputation: 64737

ZipOutputStream relative paths

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

Upvotes: 1

Views: 2840

Answers (1)

dogbane
dogbane

Reputation: 274612

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()); 

Upvotes: 4

Related Questions