Is it possible to validate a tar file in Java so that I can be sure other tar utilities (i.e UNIX tar command) can extract the tar? I would like to do this in code and not resort to actually executing tar -tf
from my application and report based on the return code.
I have been using Apache commons compress to read through a tars entries (not extract them). I have manually modified some of the tar using a text editor to represent a "corrupt" tar file. Commons compress doesn't always fail to read the entries where as the UNIX tar command or 7zip have failed consistently no matter what I modify. Obviously something more needs to be done to actually ensure the tar file is not corrupt, but what is it?
Note: I haven't actually tried to extract the tar via commons compress as a means of validation. I don't think this is really an option; the tar file sizes I have to work with are large (3 to 4 gigs) and I would rather not see this process take any longer than it already does.