0

I need to extract all the multi-part ZIP and RAR archives in a given path? Does Java have any inbuilt methods for doing this? If not, would someone happen to know of a free library that does this?

Thanks.

Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
  • You could install unzip and unrar and just invoke those. It's the easiest way assuming this is feasible in your particular scenario. – Roadmaster Nov 28 '10 at 20:17

1 Answers1

2
  1. Loop all files in the directory - new File(dir).listFiles(), possibly using a FilenameFilter to retain only those whose extension is .zip

  2. You can use the java.util.zip package, or commons-compress. But my experience shows that using the ant Zip task programatically is way easier. (You'd need the ant jar on the classpath). This is for .zip files. For RAR you'd need another utility. Take a look at this question. The URL in the answer does not open, but the name of the project is valid - google it.

Community
  • 1
  • 1
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • I found a copy using Google Code. I don't know if it is the original or if it's been modified. Does JUnrar handle multi-part/spanned archives? – Mridang Agarwalla Nov 29 '10 at 14:56