srikanth-lingala / zip4j

A Java library for zip files and streams
Apache License 2.0
2.01k stars 307 forks source link

there is some problems use fileHead to extractFile #454

Closed lzxshare closed 1 year ago

lzxshare commented 1 year ago

for example, i add some files to zipFile, they are has same file name but from different path.

A/B/word.text A/B/C/word.text F/G/word.text

when i use this way to extract file: FileHeader fileHeader = zipFile.getFileHeader("word.text"); zipFile.extractFile(fileHeader, parentFile.getAbsolutePath(), mergeName);

it extract file is not i expected, so how can i get correct file when use FileHeader ?

srikanth-lingala commented 1 year ago

You have to use the complete path in getFileHeader() method. In your case, for example, if you want to extract A/B/C/word.text, you have to use zipFile.getFileHeader("A/B/C/word.text")

lzxshare commented 1 year ago

many thanks. sir,i try your suggestions,but it got FileHeader returns null. i also debug the source code ,the zip FileHeader info only show the file name, not contains full file path. i use the library version is 2.8.0. should i use the new library version?here is debug info for FileHeads
image

srikanth-lingala commented 1 year ago

Question answered here