Interface Compressor


  • public interface Compressor
    A compressor facades a specific compression library, allowing for simple compression and decompression of files.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void compress​(java.io.File source, java.io.File destination)
      Compresses the given input file to the given destination directory or file.
      void decompress​(java.io.File source, java.io.File destination)
      Decompresses the given source file to the given destination directory or file.
      java.io.InputStream decompressingStream​(java.io.InputStream compressedStream)
      Accept a stream and wrap it in a decompressing stream suitable for the current compressor.
      java.lang.String getFilenameExtension()
      Returns the filename extension that indicates the file format this compressor handles.
    • Method Detail

      • compress

        void compress​(java.io.File source,
                      java.io.File destination)
               throws java.lang.IllegalArgumentException,
                      java.io.IOException
        Compresses the given input file to the given destination directory or file.
        Requires the source the be an existing and readable File, and the destination to be either a file or a directory. If you pass a directory, the name of the source file is used, with the appended filename extension suffix of the compression type.
        Parameters:
        source - the source file to compress
        destination - the destination file
        Throws:
        java.lang.IllegalArgumentException - if the source is not readable or the destination is not writable
        java.io.IOException - when an I/O error occurs
      • decompress

        void decompress​(java.io.File source,
                        java.io.File destination)
                 throws java.lang.IllegalArgumentException,
                        java.io.IOException
        Decompresses the given source file to the given destination directory or file.
        Requires the source the be an existing and readable File, and the destination to be either a file or a directory. If you pass a directory, the name of the source file is used, with the removed filename extension suffix of the compression type.
        Parameters:
        source - the compressed source file to decompress
        destination - the destination file
        Throws:
        java.lang.IllegalArgumentException - if the source is not readable or the destination is not writable
        java.io.IOException - when an I/O error occurs
      • decompressingStream

        java.io.InputStream decompressingStream​(java.io.InputStream compressedStream)
                                         throws java.io.IOException
        Accept a stream and wrap it in a decompressing stream suitable for the current compressor.
        Parameters:
        compressedStream - the stream of compressed data.
        Throws:
        java.io.IOException - an I/O error.
      • getFilenameExtension

        java.lang.String getFilenameExtension()
        Returns the filename extension that indicates the file format this compressor handles. E.g .gz". or ".bz2".
        Returns:
        a filename extension with a preceding dot