I asked a question about extracting RAR archives in Java, and someone pointed me to Unrara. The official site has been disabled, but it seems to be pretty widely used since I found a lot of discussion about this on the Internet.
Can someone show me how to use JUnrar to extract all files in an archive? I found a small snippet online, but it doesn't seem to work. It shows that each item in the archive is a directory, even if it is a file.
Archive rar = new Archive(new File("C://Weather_Icons.rar"));
FileHeader fh = rar.nextFileHeader();
while(fh != null){
if (fh.isDirectory()) {
logger.severe("directory: " + fh.getFileNameString() );
}
fh=rar.nextFileHeader();
}
Thank.
source
share