java,performance,optimization,uncompress,gunzip
You created your BufferedInputStream from the GZIPInputStream, for performance you would do that in the reverse order. Also, I suggest you shrink your buffer size (and use your buffered streams). Finally, I would use a try-with-resources Statement and that might look something like public static boolean ungunzip(String compressedFile, String decompressedFile)...
If your problem is that the tar.gz file contains another tar.gz file which should be extracted as well, you need a different sort of loop. The wildcard at the top of the for loop is only evaluated when the loop starts, so it doesn't include anything extracted from the tar.gz...
I solved this issue in this way : proc unzip_file_if_needed { fileName } { if { [file extension $fileName] != ".gz" } { return $fileName; } set tmpDir [fileutil::tempdir] set pId [pid] set tmpFileName [ file join $tmpDir pId ] set unzipCmd [ file join $tmpDir [ append pId "cmd.sh"...
Try using xargs: ls -Art *.sql.gz |tail -n 1 |xargs gunzip -c | mysql --user=user --password=password database ...
Here is the reverse operation using zlib.createGunzip instead of zlib.createGzip: var r = fs.createReadStream('file.txt.gz'); var z = zlib.createGunzip(); var w = fs.createWriteStream('file.txt'); r.pipe(z).pipe(w); ...