src/main/java/org/edgegallery/appstore/application/inner/AppService.java
private void deCompress(String tarFile, File destFile) {
        try (FileInputStream fis = new FileInputStream(tarFile);
             BufferedInputStream bis = new BufferedInputStream(fis);
             GZIPInputStream gzipInputStream = new GZIPInputStream(bis);
             TarArchiveInputStream tis = new TarArchiveInputStream(gzipInputStream)) {
            TarArchiveEntry tarEntry;
            while ((tarEntry = tis.getNextTarEntry()) != null) {
                if (!tarEntry.isDirectory()) {
                    File outputFile = new File(destFile + File.separator + tarEntry.getName());
                    LOGGER.info("deCompressing... {}", outputFile.getName());
                    boolean result = outputFile.getParentFile().mkdirs();
                    LOGGER.debug("create directory result {}", result);
                    FileOutputStream out = new FileOutputStream(outputFile);
                    IOUtils.copy(tis, out);
                    out.close();
                }
            }
        } catch (IOException ex) {
            throw new AppException("failed to decompress, IO exception " + ex.getMessage(),
                ResponseConst.RET_DECOMPRESS_FAILED);
        }
    }
/**
     * Decompress tar file.
     *
     * @param tarFile tar file
     * @param destFile destination folder
     */
Decompress tar file.
@param tarFile tar file
@param destFile destination folder
Decompress tar file . @param tarFile tar file @param destFile destination folder
private void deCompress(String tarFile, File destFile) {
        try (FileInputStream fis = new FileInputStream(tarFile);
             BufferedInputStream bis = new BufferedInputStream(fis);
             GZIPInputStream gzipInputStream = new GZIPInputStream(bis);
             TarArchiveInputStream tis = new TarArchiveInputStream(gzipInputStream)) {
            TarArchiveEntry tarEntry;
            while ((tarEntry = tis.getNextTarEntry()) != null) {
                if (!tarEntry.isDirectory()) {
                    File outputFile = new File(destFile + File.separator + tarEntry.getName());
                    LOGGER.info("deCompressing... {}", outputFile.getName());
                    boolean result = outputFile.getParentFile().mkdirs();
                    LOGGER.debug("create directory result {}", result);
                    FileOutputStream out = new FileOutputStream(outputFile);
                    IOUtils.copy(tis, out);
                    out.close();
                }
            }
        } catch (IOException ex) {
            throw new AppException("failed to decompress, IO exception " + ex.getMessage(),
                ResponseConst.RET_DECOMPRESS_FAILED);
        }
    }
private void deCompress ( String tarFile , File destFile ) { try ( FileInputStream fis = new FileInputStream ( tarFile ) ; BufferedInputStream bis = new BufferedInputStream ( fis ) ; GZIPInputStream gzipInputStream = new GZIPInputStream ( bis ) ; TarArchiveInputStream tis = new TarArchiveInputStream ( gzipInputStream ) ) { TarArchiveEntry tarEntry ; while ( ( tarEntry = tis . getNextTarEntry ( ) ) != null ) { if ( ! tarEntry . isDirectory ( ) ) { File outputFile = new File ( destFile + File . separator + tarEntry . getName ( ) ) ; LOGGER . info ( "deCompressing... {}" , outputFile . getName ( ) ) ; boolean result = outputFile . getParentFile ( ) . mkdirs ( ) ; LOGGER . debug ( "create directory result {}" , result ) ; FileOutputStream out = new FileOutputStream ( outputFile ) ; IOUtils . copy ( tis , out ) ; out . close ( ) ; } } } catch ( IOException ex ) { throw new AppException ( "failed to decompress, IO exception " + ex . getMessage ( ) , ResponseConst . RET_DECOMPRESS_FAILED ) ; } }
Decompress tar file.
Decompress tar file .