Class CompressionUtilities


  • public class CompressionUtilities
    extends Object
    Utility class to work with compressed files. Note that the dependency for the jarchivelib project is set with scope provided. Thus, the dependency will not automatically be introduced into a project depending on this project. This is done to keep transitive dependencies at a minimum.
    • Constructor Detail

      • CompressionUtilities

        public CompressionUtilities()
    • Method Detail

      • extract

        public static File extract​(File from,
                                   File to,
                                   boolean deleteArchive)
                            throws IOException
        Extracts the given file into the given directory. Returns a file to the extraction point of the first archive entry. This is for convenience if the archive contains a directory for quick access. The archive format is automatically determined by the underlying (de)compression library.
        Parameters:
        from - An archive file.
        to - The directory to extract the archive to.
        deleteArchive - Whether the archive file should be deleted after extraction.
        Returns:
        The path to the extracted first entry of the archive.
        Throws:
        IOException - If the archive cannot be read or files cannot be created or deleted.