I have a zip file where zip4j doesn't decode the file names correctly while all of the command line utilities and Apache's VFS2 do. From the contents of the zip file it looks like it was made on a Mac. Here is the output of test code I wrote. The first 2 lines are using Apache VFS2. The second 2 lines are from using Zip4j's ZipInputStream
Aquinas, St. Thomas/Primary/Français/Aquin - De l'éternite du monde.doc
9:Français
Aquinas, St. Thomas/Primary/Français/Aquin - De l'éternite du monde.doc
10:Français
The file is 700MB so I can't really attach it here. I tried to create a smaller file by unzipping the archive and rezipping only that file but Zip4j worked fine on the rezipped file.
I saw issue #304 which I'm not sure is related. In any case I don't have control over the zip files I'm unzipping and so I don't know the encoding beforehand.
For completeness the following is my test code. It prints out the name of the 184th entry in the zip file:
import java.io.File;
import java.io.FileInputStream;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import net.lingala.zip4j.io.inputstream.ZipInputStream;
import net.lingala.zip4j.model.LocalFileHeader;
public class TestEncoding {
public static String pickOutDirName(final String name) {
final int start = name.indexOf("Fran");
final int end = name.substring(start).indexOf('/') + start;
return name.substring(start, end);
}
public static void main(final String[] args) throws Exception {
final String fullPath = "/path/to/zip/file.zip";
final File file = new File(fullPath);
int entryCount = 0;
try(ZipArchiveInputStream isa = new ZipArchiveInputStream(new FileInputStream(file));) {
for(ArchiveEntry entry = isa.getNextEntry(); entry != null; entry = isa.getNextEntry()) {
if(entryCount == 184) {
final String name = entry.getName();
final String dirName = pickOutDirName(name);
System.out.println(name);
System.out.println(dirName.length() + ":" + dirName);
break;
}
entryCount++;
}
}
entryCount = 0;
try(ZipInputStream isz = new ZipInputStream(new FileInputStream(file));) {
for(LocalFileHeader entry = isz.getNextEntry(); entry != null; entry = isz.getNextEntry()) {
if(entryCount == 184) {
final String name = entry.getFileName();
final String dirName = pickOutDirName(name);
System.out.println(name);
System.out.println(dirName.length() + ":" + dirName);
break;
}
entryCount++;
}
}
}
}
I have a zip file where zip4j doesn't decode the file names correctly while all of the command line utilities and Apache's VFS2 do. From the contents of the zip file it looks like it was made on a Mac. Here is the output of test code I wrote. The first 2 lines are using Apache VFS2. The second 2 lines are from using Zip4j's
ZipInputStreamThe file is 700MB so I can't really attach it here. I tried to create a smaller file by unzipping the archive and rezipping only that file but Zip4j worked fine on the rezipped file.
I saw issue #304 which I'm not sure is related. In any case I don't have control over the zip files I'm unzipping and so I don't know the encoding beforehand.
For completeness the following is my test code. It prints out the name of the 184th entry in the zip file: