redho home | products | services

Programming Forums


Community for Java, PHP, Perl C, ASP and Python programmers
Wednesday 17 October 2018 14:36

Ask your IT question here

How to extract a subfolder in a gzip?



 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Programming Forums -> JAVA programming forum
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
 
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Programming Forums -> JAVA programming forum


Dubai Forums - Expat Help | Vegan Forum | Java Programming | 3d Design Resources | 3d Forum | 3D Jobs | 3D Textures | Paris Forum | Europe Forum
Dubai Classifieds | Dubai Property | Jobs in Dubai | Free London Classifieds | Jobs in London UK

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

© 2018 RedHo