Java – extract files using junrar
                                        
                    •
                    Java                                    
                I asked a question about extracting rar files in Java. Someone pointed me to junrar The official website has been closed, but it seems to be widely used because I found a lot of discussion about it on the Internet
Can someone tell me how to use junrar to extract all the files in the archive? I found a small clip on the Internet, but it didn't seem to work It displays each item in the archive as 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() ); 
        }
        //File out = new File(fh.getFileNameString());
        //FileOutputStream os = new FileOutputStream(out);
        //rar.extractFile(fh,os);
        //os.close();
        fh=rar.nextFileHeader();
    }
thank you.
Solution
Maybe you should check this snippet
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        