Java中是否有用于解压缩.deb(debian)压缩文件的库?不幸的是我找不到任何有用的东西。谢谢。使用Java打开debian软件包
回答
如果您通过解包意味着解压文件,应该可以使用Apache Commons Compress。 .deb文件是“implemented as an ar archive”,Commons Compress能够解压缩存档。
谢谢,我一定会尝试Apache Commons Compress ...没注意到“ar档案”部分。 –
请注意,顶级'ar'档案库将包含两个'tar'档案,但显然ACC也应对这一问题。 – tripleee
好吧,所以建议我使用apache commons compress,这里有一个方法可以实现。从Maven回购下载:http://mvnrepository.com/artifact/org.apache.commons/commons-compress/1.2。
/**
* Unpack a deb archive provided as an input file, to an output directory.
* <p>
*
* @param inputDeb the input deb file.
* @param outputDir the output directory.
* @throws IOException
* @throws ArchiveException
*
* @returns A {@link List} of all the unpacked files.
*
*/
private static List<File> unpack(final File inputDeb, final File outputDir) throws IOException, ArchiveException {
LOG.info(String.format("Unzipping deb file %s.", deb.getAbsoluteFile()));
LOG.info(String.format("Into dir %s.", outDir.getAbsoluteFile()));
final List<File> unpackedFiles = new LinkedList<File>();
final InputStream is = new FileInputStream(inputDeb);
final ArArchiveInputStream debInputStream = (ArArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream("ar", is);
ArArchiveEntry entry = null;
while ((entry = (ArArchiveEntry)debInputStream.getNextEntry()) != null) {
LOG.info("Read entry");
final File outputFile = new File(outputDir, entry.getName());
final OutputStream outputFileStream = new FileOutputStream(outputFile);
IOUtils.copy(debInputStream, outputFileStream);
outputFileStream.close();
unpackedFiles.add(outputFile);
}
debInputStream.close();
return unpackedFiles;
}
我对上述源代码进行了更正。请注意,“entry”变量可能代表一个目录。在这种情况下,请添加检查if(entry.isDirectory())并确保创建所需的目录。 –
- 1. Shoes Debian软件包
- 2. 在Debian软件包中启动Java 7
- 3. 使用Apache Ant创建Debian软件包
- 4. 我需要使用Java + OpenGL构建Ubuntu/Debian软件包吗?
- 5. CMake CPack debian软件包
- 6. debian软件包装教程
- 7. Debian软件包验证
- 8. Debian软件包不提供?
- 9. 如何将cassandra源代码打包到debian软件包中?
- 10. Debian软件包包含base64.h
- 11. Java如何制作软件包启动器,打开项目中的软件包
- 12. 打包专业用的Java软件
- 13. 重建软件包和debian上的软件包管理器
- 14. Debian软件包分发和组件
- 15. Debian软件包控制文件问题
- 16. 如何使用CPack将文件添加到debian软件包?
- 17. debian软件包更新原子?
- 18. Debian软件包创建错误
- 19. 签署并发布debian软件包
- 20. 建立一个Debian软件包Tensorflow
- 21. 从debian/rules安装软件包
- 22. 重建opencv 2.1 debian软件包
- 23. 提取Debian软件包的描述
- 24. 在CentOS上创建Debian软件包
- 25. Debian软件包卸载过程
- 26. 从Ruby宝石创建Debian软件包
- 27. soname的Debian软件包命名策略
- 28. 与leiningen构建Debian和Redhat软件包
- 29. Debian 8:无法找到软件包
- 30. $(SUDO_USER)Debian软件包中的变量makefile
你是说打开存档来检查它的内容还是实际部署存档? – Peter
用户写了“...用于解包.deb ...”,因此他可能意味着提取。 – noamt
我想解压并将档案部署到临时文件夹。因此,如果.deb存档文件包含文件/文件夹X,Y,Z,我想将X,Y,Z提取到临时文件夹中,请说“T”并能够创建“新文件(T,X)”。 –