Package adams.core.io

Class LzmaUtils


  • public class LzmaUtils
    extends Object
    Helper class for lzma related operations.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • LzmaUtils

        public LzmaUtils()
    • Method Detail

      • decompress

        public static String decompress​(File archiveFile,
                                        int buffer)
        Decompresses the specified lzma archive to a file without the ".7z" extension.
        Parameters:
        archiveFile - the gzip file to decompress
        buffer - the buffer size to use
        Returns:
        the error message, null if everything OK
      • decompress

        public static String decompress​(File archiveFile,
                                        int buffer,
                                        File outputFile)
        Decompresses the specified lzma archive.
        Parameters:
        archiveFile - the lzma file to decompress
        buffer - the buffer size to use
        outputFile - the destination file
        Returns:
        the error message, null if everything OK
      • compress

        public static String compress​(File inputFile,
                                      int buffer)
        Compresses the specified lzma archive to a file with the ".7z" extension.
        Parameters:
        inputFile - the file to compress
        buffer - the buffer size to use
        Returns:
        the error message, null if everything OK
      • compress

        public static String compress​(File inputFile,
                                      int buffer,
                                      File outputFile)
        Compresses the specified lzma archive. Does not remove the input file.
        Parameters:
        inputFile - the file to compress
        buffer - the buffer size to use
        outputFile - the destination file (the archive)
        Returns:
        the error message, null if everything OK
      • compress

        public static String compress​(File inputFile,
                                      int buffer,
                                      File outputFile,
                                      boolean removeInput)
        Compresses the specified lzma archive.
        Parameters:
        inputFile - the file to compress
        buffer - the buffer size to use
        outputFile - the destination file (the archive)
        removeInput - whether to remove the input file
        Returns:
        the error message, null if everything OK
      • compress

        public static byte[] compress​(byte[] input)
        Compresses the specified bytes using lzma.
        Parameters:
        input - the bytes to compress
        Returns:
        the compressed bytes, null in case of error
      • compress

        public static byte[] compress​(byte[] input,
                                      MessageCollection errors)
        Compresses the specified bytes using lzma.
        Parameters:
        input - the bytes to compress
        Returns:
        the compressed bytes, null in case of error
      • decompress

        public static byte[] decompress​(byte[] input,
                                        int buffer)
        Decompresses the specified gzip compressed bytes.
        Parameters:
        input - the compressed bytes
        buffer - the buffer size to use
        Returns:
        the decompressed bytes, null in case of error
      • decompress

        public static byte[] decompress​(byte[] input,
                                        int buffer,
                                        MessageCollection errors)
        Decompresses the specified gzip compressed bytes.
        Parameters:
        input - the compressed bytes
        buffer - the buffer size to use
        errors - for collecting errors
        Returns:
        the decompressed bytes, null in case of error