title: Extracting a file with JUnrar
body: <p>I asked a question earlier about extracting RAR archives in Java and someone pointed me to JUnrar. The official site is down but it seems to be quite widely used as I found a lot of discussions about it online.</p>
  
  <p>Could someone show me how to use JUnrar to extract all the files in an archive? I found a little snippet online but it doesn't seem to work. It shows each item in the archive to be a directory even if it is a file.</p>
  
  <pre><code>    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();
  
      }
  </code></pre>
  
  <p>Thanks.</p>