public static void ungzip(String srcFile,String destDir) throws IOException {
  String tempDestFileName=srcFile.substring(0,srcFile.lastIndexOf("."));
  tempDestFileName=tempDestFileName.substring(srcFile.lastIndexOf(FILE_SEPARATOR) + 1);
  File bdbDir=new File(destDir);
  if (!bdbDir.exists()) {
    bdbDir.mkdir();
    byte[] buffer=new byte[BUFFER_SIZE];
    GZIPInputStream gzin=new GZIPInputStream(new FileInputStream(srcFile));
    FileOutputStream fout=new FileOutputStream(new File(destDir,tempDestFileName));
    int byteRead=0;
    while ((byteRead=gzin.read(buffer)) != -1) {
      fout.write(buffer,0,byteRead);
    }
    gzin.close();
    fout.close();
  }
}

public static void ungzip ( String srcFile , String destDir ) throws IOException { String tempDestFileName = srcFile . substring ( 0 , srcFile . lastIndexOf ( "." ) ) ; tempDestFileName = tempDestFileName . substring ( srcFile . lastIndexOf ( FILE_SEPARATOR ) + 1 ) ; File bdbDir = new File ( destDir ) ; if ( ! bdbDir . exists ( ) ) { bdbDir . mkdir ( ) ; byte [ ] buffer = new byte [ BUFFER_SIZE ] ; GZIPInputStream gzin = new GZIPInputStream ( new FileInputStream ( srcFile ) ) ; FileOutputStream fout = new FileOutputStream ( new File ( destDir , tempDestFileName ) ) ; int byteRead = 0 ; while ( ( byteRead = gzin . read ( buffer ) ) != - 1 ) { fout . write ( buffer , 0 , byteRead ) ; } gzin . close ( ) ; fout . close ( ) ; } }
ungzip the gzip archive from source file to destinated directory .
