Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3437534
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:04:38+00:00 2026-05-18T08:04:38+00:00

I asked a question earlier about extracting RAR archives in Java and someone pointed

  • 0

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.

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.

    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();

    }

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:04:39+00:00Added an answer on May 18, 2026 at 8:04 am

    May be you should also check this snippet code. A copy of which can be found below.

    public class MVTest {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            String filename = "/home/rogiel/fs/home/movies/vp.mp3.part1.rar";
            File f = new File(filename);
            Archive a = null;
            try {
                a = new Archive(new FileVolumeManager(f));
            } catch (RarException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (a != null) {
                a.getMainHeader().print();
                FileHeader fh = a.nextFileHeader();
                while (fh != null) {
                    try {
                        File out = new File("/home/rogiel/fs/test/"
                                + fh.getFileNameString().trim());
                        System.out.println(out.getAbsolutePath());
                        FileOutputStream os = new FileOutputStream(out);
                        a.extractFile(fh, os);
                        os.close();
                    } catch (FileNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (RarException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    fh = a.nextFileHeader();
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked a question earlier about ESBs written in Erlang or Java, and there
i had asked earlier about the same kind of question but that was in
In an earlier question, I asked about typecasting pointers, but was directed to the
I asked an earlier question about absolute and relative div positioning , but I
I had asked a question about this earlier, but it didn't get answered right
I asked a simialr question earlier about using jquery and hashtags but what I
I asked a question about this earlier but received no responses, so I'm trying
Ok, I asked a question earlier about Flex and ADO.NET Data Services but didn't
asked a question on my project earlier but it seems im learning more about
I asked a question earlier about why left joins in Linq can't use defined

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.