Reputation: 1063
I want to extract files from a .cab file and save them. I could not find any useful information on other questions and on GitHub there is no documentation.
For now I can iterate through all entries (2 text files) with CAB Parser but I cannot find a good way to save them and would appreciate some hints.
File inputFile = new File(inputPath);
File outputPath = new File(inputFile.getParentFile().getAbsolutePath());
final InputStream is = new FileInputStream(inputFile);
CabParser cabParser = new CabParser(is, inputPath);
Arrays.stream(cabParser.files).forEach(element -> {
CabFileEntry cabFile = element;
});
Thanks a lot!
Upvotes: 0
Views: 903
Reputation: 2677
This seems to work with simple.cab:
final InputStream is = new FileInputStream("/tmp/simple.cab");
CabParser cabParser = new CabParser(is, new File("/tmp/simple/"));
cabParser.extractStream();
However, it fails with VC_RED.cab
.
CabParser README.md:
extract files from within a .cab which are compressed via the LZX compression algorithm
Maybe not all the possible compression algorithms are supported by this library.
One option is to run cabextract with Runtime.exec(...).
Upvotes: 1