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.
import java.io.*;
import java.util.zip.*;
import org.apache.tools.ant.taskdefs.Untar;
public class Main {
public static void main(String[] args) {
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();
}
}
}
Edited by dargueta, 18 October 2010 - 08:49 PM.
Added code tags


Sign In
Create Account

Back to top









