I am looking for a way to read the contents of an RPM during Java runtime.
Someone suggested using 7zip to unpack and / or extract RPMs at runtime using the system command for 7zip.
This solution has two drawbacks:
- It depends on the platform (since the commands will be specific to one OS)
- It uses third-party software.
any ideas?
EDIT:
I'm trying to go down Robert's road. Here is my code:
String file = "MyRpm.rpm"; CpioArchiveInputStream cpioIn = new CpioArchiveInputStream( new FileInputStream(new File(file)) ); CpioArchiveEntry cpioEntry; while ((cpioEntry = cpioIn.getNextEntry()) != null) { System.out.println(cpioEntry.getName()); int tmp; StringBuffer buf = new StringBuffer(); while ((tmp = cpioIn.read()) != -1) { buf.append((char) tmp); } System.out.println(buf.toString()); } cpioIn.close();
I get an exception: java.io.IOException: Unknown magic [????
(Funny characters from the original error message).
source share