Monday 15 March 2010

java - tar.gz decompression failing using apache commons-compress -



java - tar.gz decompression failing using apache commons-compress -

hi guys using apache commons-compress 1.9 compress , decompress tar.gz file. issue facing while decompressing file. while decompressing saying files within compressed folder not found. next decompressing code

public static boolean uncompresstargz(string tarfilename, string outputdir, logger log) throws ioexception { seek (tararchiveinputstream tararchiveinputstream = new tararchiveinputstream(new gzipcompressorinputstream(new fileinputstream(tarfilename)))) { tararchiveentry tarentry = (tararchiveentry) tararchiveinputstream.getnextentry(); log.info("outputdir : " + outputdir); log.info("tar file name : " + tarfilename); files.createdirectories(paths.get(outputdir)); while (tarentry != null) { log.info("tarentry : " + tarentry.getname()); file destpath = new file(outputdir, tarentry.getname()); log.info("1"); if (!tarentry.isdirectory()) { destpath.createnewfile(); log.info("2"); seek (fileoutputstream fout = new fileoutputstream(destpath);) { ioutils.copy(tararchiveinputstream, fout); } grab (throwable e) { log.info("error : " + e + " reason : " + e.getmessage()); } log.info("3"); // byte[] buffer = new byte[8192]; // int n = 0; // while (-1 != (n = tararchiveinputstream.read(buffer))) { // fout.write(buffer, 0, n); // } } else { destpath.mkdir(); } tarentry = (tararchiveentry) tararchiveinputstream.getnextentry(); } homecoming true; } grab (throwable e) { log.info("exception while untar : " + e.getmessage()); homecoming false; } }

i getting error /tmp/customtar/customfiles/filessucceeded (no such file or directory).

can please help me figure out might doing wrong.

thanks in advance.

java tar decompression

No comments:

Post a Comment