Git Product home page Git Product logo

junrar's Introduction

Build Status Download codecov

Junrar

Read and extracts from a .rar file. This is a fork of the junrar codebase, formerly on sourceforge.

Code may not be used to develop a RAR (WinRAR) compatible archiver.

Supported features

  • RAR 4 and lower (there is no RAR 5 support)
  • password protected archives (also with encrypted headers)
  • multi-part archives
  • extract from File and InputStream
  • extract to File and OutputStream

Installation

Gradle
implementation "com.github.junrar:junrar:{version}"
Gradle (Kotlin DSL)
implementation("com.github.junrar:junrar:{version}")
Maven
<dependency>
    <groupId>com.github.junrar</groupId>
    <artifactId>junrar</artifactId>
    <version>{version}</version>
</dependency>

where {version} corresponds to version as below:

  • Java 8 Version: Download
  • Java 6 Compatible Version: Download

Apache Commons VFS support has been removed from 5.0.0, and moved to a dedicated repo: https://github.com/junrar/commons-vfs-rar

Usage

Extract from a file to a directory:

Junrar.extract("/tmp/foo.rar", "/tmp");
//or
final File rar = new File("foo.rar");  
final File destinationFolder = new File("destinationFolder");
Junrar.extract(rar, destinationFolder);    
//or
final InputStream resourceAsStream = Foo.class.getResourceAsStream("foo.rar");//only for a single rar file
Junrar.extract(resourceAsStream, tempFolder);

Extract from an InputStream to an OutputStream

// Assuming you already have an InputStream from the rar file and an OutputStream for writing to
final Archive archive = new Archive(inputStream);
  while (true) {
      FileHeader fileHeader = archive.nextFileHeader();
      if (fileHeader == null) {
          break;
      }
      archive.extractFile(fileHeader, outputStream); 
  }

List files

final List<ContentDescription> contentDescriptions = Junrar.getContentsDescription(testDocuments);    

Extract a password protected archive

Junrar.extract("/tmp/foo.rar", "/tmp", "password");
//or
final File rar = new File("foo.rar");  
final File destinationFolder = new File("destinationFolder");
Junrar.extract(rar, destinationFolder, "password");    
//or
final InputStream resourceAsStream = Foo.class.getResourceAsStream("foo.rar");//only for a single rar file
Junrar.extract(resourceAsStream, tempFolder, "password");

Extract a multi-volume archive

Junrar.extract("/tmp/foo.001.rar", "/tmp");

junrar's People

Contributors

beothorn avatar gotson avatar theobisproject avatar edmund-wagner avatar semantic-release-bot avatar dependabot[bot] avatar sunny-shu avatar rogiel avatar xavier630 avatar nawa avatar tballison avatar befora avatar robbwatershed avatar nadahar avatar mingun avatar icirellik avatar awaters1 avatar 0xanasezz avatar alecharp avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.