I am trying to use the Apache Commons Compress to read the content of a 7-zip file. I'm not interested in reading/extracting the content, I just want to get the list of all the entries.
I made this code, but with 4MB archives it takes 6 seconds to read the whole file.
public static void main(String[]args) throws IOException{
File sevenz = new File("testfile.7z");
System.out.println("Reading 7-zip...");
SevenZFile sevenZFile = new SevenZFile(sevenz);
long s = System.currentTimeMillis();
SevenZArchiveEntry entry;
while((entry=sevenZFile.getNextEntry())!=null){
System.out.print(entry.isDirectory()?"Dir":"File");
System.out.print("\t");
System.out.print("*********.***"); //entry.getName();
System.out.print("\t");
System.out.println(entry.getHasCrc()?"CRC":"NO-CRC");
}
System.out.println("------------------------------");
System.out.println("7-zip\t"+(System.currentTimeMillis()-s)+" ms to read.");
}
The output is:
Reading 7-zip...
File *********.*** CRC
File *********.*** CRC
File *********.*** CRC
File *********.*** CRC
File *********.*** CRC
------------------------------
7-zip 6236 ms to read.
Is the file listing process supposed to take all this time or am I doing something wrong? I also tried to remove all the prints, but the time it takes to read the file is the same.