title: How to make compression more faster in java to archiving file
body: <p>I am working on java application, where I have to manage the files into tar/zip format. So I am creating tar/zip from csv file. 
  Now I am looking for the way, by which I can do it faster. Because I have to run this for millions of files.</p>
  
  <p>I am using following code and what to make it more faster.
  Following Libs are Using...</p>
  
  <p><strong>FileUtils</strong> of org.apache.commons.io</p>
  
  <p><strong>TarArchiveEntry</strong> of org.apache.commons.compress.archivers.tar</p>
  
  <pre><code>try {
          // Create staging file output stream
          File temp = new File(getFilePath(objectm));
          log.debug("temping " + objectm.getPath());
          outputStream = new FileOutputStream(temp);
  
          // Create GZip pass-thru stream
          if (isCompressionEnabled) {
              compressionStream = new
                      CompressionStream(outputStream, getCompressionLevel(objectm));
          }
  
          // Create MD5 hash
          final MessageDigest outputDigest = MessageDigest.getInstance("MD5");
          md5OutputStream = new DigestOutputStream(isCompressionEnabled ? compressionStream : outputStream, outputDigest);
  
          // Create tar stream
          tarStream = new TarArchiveOutputStream(new BufferedOutputStream(md5OutputStream));
          tarStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
          tarStream.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_STAR);
  
          // tar the first object
          TarArchiveEntry entry = new TarArchiveEntry(objectm.getHierarchy());
          entry.setSize(objectm.getOriginalSize());
          entry.setModTime(objectm.getLastModified().getMillis());
          tarStream.putArchiveEntry(entry);
          org.apache.commons.io.IOUtils.copyLarge(inputStream, tarStream);
  
  
          // Collect properties to return
          String digest = Hex.encodeHexString(outputDigest.digest());
          objectm.setChecksum(digest);
          objectm.setDate(DateTime.now());
          objectm.setCompressSize(FileUtils.sizeOf(temp));          
          tarStream.finish();
          log.debug("Completed.");
  
      } catch (Exception e) {
          throw new Exception("Exception: Creating tar" , e);
      } finally {
          org.apache.cobjectmmons.io.IOUtils.closeQuietly(inputStream);
          org.apache.cobjectmmons.io.IOUtils.closeQuietly(tarStream);
          org.apache.cobjectmmons.io.IOUtils.closeQuietly(cobjectmpressionStream);
          org.apache.cobjectmmons.io.IOUtils.closeQuietly(md5OutputStream);
          org.apache.cobjectmmons.io.IOUtils.closeQuietly(outputStream);
      }
  </code></pre>
  
  <p>Here in second method we are moving the object from temp to actual location.</p>
  
  <pre><code>try {
          File src = new File(getFilePath(objectm));
          File dst = new File(sDestinationFile);
          FileUtils.moveFile(src, dst);
          boolean readableFlag = dst.setReadOnly();
      } catch (IOException e) {
          throw new Exception("Unable to move to destination.", e);
      }
  </code></pre>