How can I extract all multi-part ZIP/RAR archives in a directory?
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?
Than开发者_JAVA百科ks.
Loop all files in the directory -
new File(dir).listFiles()
, possibly using aFilenameFilter
to retain only those whose extension is .zipYou 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.
精彩评论