As part of my daytime job I’ve had to look at a solution for uncompressing RAR files using Java. There is a nice library out there, even though it is hard to find: java-unrar.
The only downside of java-unrar, as far as I can tell so far, is that it only works with files (
java.io.File). For this particular project I needed something that works on an input stream, though.
Research quickly showed that others have had similar problems. Unfortunately, I couldn’t find a good solution other than using temp files, etc. After some more research I finally found ImageJ, a library for – you might have guessed – image processing. However, this library includes a nice helper class:
RandomAccessStream. This class implements exactly what I needed.
So, what I ended up with was changing java-unrar to not only accept files, but also instances of
IReadOnlyAccess, a simple random access interface. Using
RandomAccessStream it was simple to implement.
So far this seems to be working well.