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. Debian軟件包不提供?
- 6. Debian軟件包驗證
- 7. CMake CPack debian軟件包
- 8. debian軟件包裝教程
- 9. 將Debian軟件包分發到Debian軟件包並安裝其他東西
- 10. 如何將cassandra源代碼打包到debian軟件包中?
- 11. Debian軟件包包含base64.h
- 12. Java如何製作軟件包啓動器,打開項目中的軟件包
- 13. 打包專業用的Java軟件
- 14. 重建軟件包和debian上的軟件包管理器
- 15. Debian軟件包分發和組件
- 16. Debian軟件包控制文件問題
- 17. 如何使用CPack將文件添加到debian軟件包?
- 18. 構建無上游的Debian軟件包
- 19. $(SUDO_USER)Debian軟件包中的變量makefile
- 20. Debian 8:無法找到軟件包
- 21. 在CentOS上創建Debian軟件包
- 22. 在debian上安裝實驗軟件包
- 23. soname的Debian軟件包命名策略
- 24. Debian軟件包卸載過程
- 25. 安裝Debian軟件包更改配置
- 26. 建立一個Debian軟件包Tensorflow
- 27. 簽署併發布debian軟件包
- 28. 提取Debian軟件包的描述
- 29. 從Ruby寶石創建Debian軟件包
- 30. 從debian/rules安裝軟件包
你是說打開存檔來檢查它的內容還是實際部署存檔? – Peter
用戶寫了「...用於解包.deb ...」,因此他可能意味着提取。 – noamt
我想解壓並將檔案部署到臨時文件夾。因此,如果.deb存檔文件包含文件/文件夾X,Y,Z,我想將X,Y,Z提取到臨時文件夾中,請說「T」並能夠創建「新文件(T,X)」。 –