How to extract a subfolder in a gzip?
|
View previous topic :: View next topic |
Author |
Message |
RedBuLL Guest Programmer
|
Hi, I have a .tar.gz file which contains a folder 'tree', and a file called 'log.txt' inside the folder 'tree'. I need to decompress the gzip to extract the log.txt.
Problem with my code is the first line of the output contains the path directory and some random numbers followed by the actual log.txt result. This is due to the folder 'tree' inside the gzip. Anyone who knows how to open the subfolder inside a gzip please help!!!! Thanks a lot.
try{
GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream("C:\\myfile.tar.gz"));
InputStream is = new Untar.UntarCompressionMethod().decompress("", gzipInputStream);
byte[] iFile = new byte[1024];
File f=new File("outFile");
OutputStream out=new FileOutputStream(f);
int len;
while((len=is.read(iFile)) > 0)
out.write(iFile,0,len);
is.close();
out.close();
}
catch(Exception e){
e.printStackTrace();
}
Reply with quote
|
|
|
|
|