简体   繁体   English

在Android中解压缩Rar文件

[英]Decompress Rar file in Android

I want to learn how to decompress a .rar file in android. 我想学习如何在android中解压缩.rar文件。 Zip files can be easily decompressed using ZipStream. Zip文件可以使用ZipStream轻松解压缩。 Is there any similar way for rar files. rar文件有没有类似的方法。

I just realized this with jUnrar from here https://github.com/edmund-wagner/junrar 我刚刚从这里通过jUnrar实现了这一点https://github.com/edmund-wagner/junrar

Create a new package within your Android src directory called com.github.junrar You should delete com.github.junrar.vfs2 because it has some dependencies and you probably won't use it anyway. 在你的Android src目录中创建一个名为com.github.junrar的新软件包你应该删除com.github.junrar.vfs2,因为它有一些依赖项,你可能还是不会使用它。

You will probably get some errors about the logger class. 您可能会遇到有关记录器类的错误。 You can either remove the few logging lines or like i did write a tiny wrapper which communicates with android.util.Log. 你可以删除一些日志记录行,或者像我写了一个与android.util.Log通信的小包装器。 I did that and changed the includes. 我这样做了,改变了包含。

If you finished importing the code take a look at jUnrars testutils. 如果您完成了代码导入,请查看jUnrars testutils。 I used this and it worked out of the box: 我用过这个,开箱即用:

https://github.com/edmund-wagner/junrar/blob/master/testutil/src/main/java/com/github/junrar/testutil/ExtractArchive.java https://github.com/edmund-wagner/junrar/blob/master/testutil/src/main/java/com/github/junrar/testutil/ExtractArchive.java

Hope it helps 希望能帮助到你

RAR isn't very commonly used (except in certain niches), so you won't find support for it built into the Android libraries. RAR不是很常用(除了在某些利基中),因此你不会在Android库中找到对它的支持。 Probably the easiest thing to do is to get a Java library that handles RAR files, as covered in this question: 可能最简单的方法是获取一个处理RAR文件的Java库,如本问题所述:

RAR archives with java RAR档案与java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM