Class TarUtils

java.lang.Object
com.compomics.util.io.compression.TarUtils

public class TarUtils
extends Object
This class contains convenience methods for taring files.
Author:
Marc Vaudel
  • Field Details

  • Constructor Details

    • TarUtils

      public TarUtils()
      Empty default constructor
  • Method Details

    • tarFolder

      public static void tarFolder​(File folder, File destinationFile, WaitingHandler waitingHandler) throws org.apache.commons.compress.archivers.ArchiveException, IOException
      Tar a given folder to a file.
      Parameters:
      folder - The original folder to tar.
      destinationFile - The destination file.
      waitingHandler - A waiting handler used to cancel the process (can be null).
      Throws:
      org.apache.commons.compress.archivers.ArchiveException - Thrown whenever an error occurred while taring.
      IOException - Thrown whenever an error occurred while reading/writing files.
    • tarFolderContent

      public static void tarFolderContent​(File folder, File destinationFile, HashSet<String> exceptionsPaths, WaitingHandler waitingHandler) throws org.apache.commons.compress.archivers.ArchiveException, IOException
      Tar the content of a given folder to a file.
      Parameters:
      folder - the original folder to tar
      destinationFile - the destination file
      exceptionsPaths - a list of paths to files or folders which should be excluded from taring
      waitingHandler - a waiting handler used to cancel the process (can be null)
      Throws:
      org.apache.commons.compress.archivers.ArchiveException - exception thrown whenever an error occurred while taring
      IOException - exception thrown whenever an error occurred while reading/writing files
    • addFolderContent

      public static void addFolderContent​(org.apache.commons.compress.archivers.ArchiveOutputStream tarOutput, File folder, WaitingHandler waitingHandler) throws IOException
      Add content to the tar file.
      Parameters:
      tarOutput - the archive output stream
      folder - the folder to add
      waitingHandler - a waiting handler used to cancel the process (can be null)
      Throws:
      IOException - exception thrown whenever an error occurred while reading/writing files
    • extractFile

      public static void extractFile​(File tarFile, WaitingHandler waitingHandler) throws org.apache.commons.compress.archivers.ArchiveException, IOException
      Extracts files from a tar.
      Parameters:
      tarFile - the tar file
      waitingHandler - a waiting handler displaying progress and allowing canceling the process
      Throws:
      org.apache.commons.compress.archivers.ArchiveException - if an ArchiveException occurs
      IOException - if an IOException occurs
    • extractFile

      public static void extractFile​(File tarFile, File destinationFolder, WaitingHandler waitingHandler) throws org.apache.commons.compress.archivers.ArchiveException, IOException
      Extracts files from a tar.
      Parameters:
      tarFile - the tar file
      destinationFolder - the destination folder, if null the file will be extracted according to the archive name
      waitingHandler - a waiting handler displaying progress and allowing canceling the process
      Throws:
      org.apache.commons.compress.archivers.ArchiveException - if an ArchiveException occurs
      IOException - if an IOException occurs