@@ -0,0 +1,2773 @@
+package org.fugerit.java.tool.compress;%0D%0A%0D%0Aimport java.io.File;%0D%0Aimport java.io.FileInputStream;%0D%0Aimport java.io.FileNotFoundException;%0D%0Aimport java.io.FileOutputStream;%0D%0Aimport java.io.IOException;%0D%0Aimport java.util.zip.ZipEntry;%0D%0Aimport java.util.zip.ZipOutputStream;%0D%0A%0D%0Aimport org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;%0D%0Aimport org.apache.commons.compress.archivers.sevenz.SevenZOutputFile;%0D%0Aimport org.apache.commons.compress.utils.IOUtils;%0D%0Aimport org.fugerit.java.core.io.StreamIO;%0D%0A%0D%0Apublic class CompressUtils %7B%0D%0A%0D%0A%09public static void compress7Zipfile( File sourceDir, File  outputFile) throws IOException, FileNotFoundException %7B%0D%0A%09%09SevenZOutputFile zipFile = new SevenZOutputFile( outputFile );%0D%0A%09    compressDirectoryTo7Zipfile(sourceDir, sourceDir, zipFile);%0D%0A%09    IOUtils.closeQuietly(zipFile);%0D%0A%09%7D%0D%0A%09%0D%0A%09private static void compressDirectoryTo7Zipfile(File rootDir, File sourceDir, SevenZOutputFile out) throws IOException, FileNotFoundException %7B%0D%0A%09    for (File file : sourceDir.listFiles()) %7B%0D%0A%09        if (file.isDirectory()) %7B%0D%0A%09        %09compressDirectoryTo7Zipfile(rootDir, new File( sourceDir , file.getName() ), out);%0D%0A%09        %7D else %7B%0D%0A%09        %09String entryName = sourceDir.getCanonicalPath().replace(rootDir.getCanonicalPath(), %22%22) + file.getName();%0D%0A%09        %09SevenZArchiveEntry entry = out.createArchiveEntry( file , entryName);%0D%0A%09        %09out.putArchiveEntry( entry );%0D%0A%09        %09FileInputStream in = new FileInputStream( file );%0D%0A%09        %09byte%5B%5D buffer = new byte%5B1024%5D;%0D%0A%09        %09int read = in.read( buffer ); %0D%0A%09        %09while ( read %3E 0 ) %7B%0D%0A%09        %09%09out.write( buffer, 0, read );%0D%0A%09        %09%09read = in.read( buffer );%0D%0A%09        %09%7D%0D%0A%09        %09in.close();%0D%0A%09        %09out.closeArchiveEntry();%0D%0A%09        %7D%0D%0A%09    %7D%0D%0A%09%7D%0D%0A%09%0D%0A%09public static void compressZipfile( File sourceDir, File  outputFile) throws IOException, FileNotFoundException %7B%0D%0A%09    ZipOutputStream zipFile = new ZipOutputStream(new FileOutputStream(outputFile));%0D%0A%09    compressDirectoryToZipfile(sourceDir, sourceDir, zipFile);%0D%0A%09    IOUtils.closeQuietly(zipFile);%0D%0A%09%7D%0D%0A%09%0D%0A%09private static void compressDirectoryToZipfile(File rootDir, File sourceDir, ZipOutputStream out) throws IOException, FileNotFoundException %7B%0D%0A%09    for (File file : sourceDir.listFiles()) %7B%0D%0A%09        if (file.isDirectory()) %7B%0D%0A%09            compressDirectoryToZipfile(rootDir, new File( sourceDir , file.getName() ), out);%0D%0A%09        %7D else %7B%0D%0A%09            ZipEntry entry = new ZipEntry(sourceDir.getCanonicalPath().replace(rootDir.getCanonicalPath(), %22%22) + file.getName());%0D%0A%09            out.putNextEntry(entry);%0D%0A%09            FileInputStream in = new FileInputStream( file );%0D%0A%09            StreamIO.pipeStream( in , out, StreamIO.MODE_CLOSE_IN_ONLY );%0D%0A%09        %7D%0D%0A%09    %7D%0D%0A%09%7D%0D%0A%09%0D%0A%7D%0D%0A

Compress Utils