Ok so I want to read the contents of a tar.gz file (or a xy) but that's the same thing. What I am doing is more or less this:
TarArchiveInputStream tarInput = new TarArchiveInputStream(new GzipCompressorInputStream(new FileInputStream("c://temp//test.tar.gz")));
TarArchiveEntry currentEntry = tarInput.getNextTarEntry();
BufferedReader br = null;
StringBuilder sb = new StringBuilder();
while (currentEntry != null) {
File f = currentEntry.getFile();
br = new BufferedReader(new FileReader(f));
System.out.println("For File = " + currentEntry.getName());
String line;
while ((line = br.readLine()) != null) {
System.out.println("line="+line);
}
}
if (br!=null) {
br.close();
}
But I get null when I call the getFile
method of TarArchiveEntry
.
I am using Apache commons compress 1.8.1