Archiver (part 12)

  • 16
  • Locked
Today we'll prepare to implement ZipContentCommand. It will be responsible for getting an archive's contents. The archive's contents are compressed files and folders, but we're interested in knowing not only the names of the archive's objects, but also their size before and after compression.
You can't complete this task, because you're not signed in.
Comments (5)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 30 , Prague, Czech Republic
20 March 2022, 21:34
public String toString() {
        if (size > 0) return String.format("%s %.2fKB (%.2fKB) compression : %d%%",
                name, size / 1024.0, compressedSize / 1024.0, getCompressionRatio());
        else return name;
Please help me, I don't see where the mistake is. I convert B to KB by 1024.0 - the result is double and format it with %.2f and then compress ratio as long format with %d. What I don't see? I've tested it separately with same kind of values and it works fine.
Level 30 , Prague, Czech Republic
20 March 2022, 21:41
I passed with the most stupid thing: everything formatted with %d. Soo, If my input file has for example size 1048B and compressed size is 257B, then the output is 1 KB (0 KB). Oh, common. If I do it as it should be, then I don't pass the control. This part of control doesn't work correctly!
Level 31 , Duisburg, Germany
18 February 2021, 14:22
They want Kibibytes, not Kilobytes.
Guadalupe Gagnon
Level 37 , Tampa, United States
4 May 2019, 15:37
"name size KB (compressedSize KB) compression: getCompressionRatio()%" Here is what they are asking for on the toString() method, where the bold parts are variable or method calls. Make sure that you convert bytes to kilobytes as per computer science and not per the metric system.
jorge ives murillo paredes
Level 40 , New York City, United States
19 April 2020, 05:26
thanks bro,you help a lot.