Class StorerEncryption


  • public class StorerEncryption
    extends Object
    Utility methods useful for those Storers that supports the encryption
    Since:
    7.7.1
    Author:
    Marco Meschieri - LogicalDOC
    • Constructor Detail

      • StorerEncryption

        public StorerEncryption()
    • Method Detail

      • getStream

        public static InputStream getStream​(File file,
                                            String resource,
                                            boolean useAutoDelete)
                                     throws Exception
        Retrieves the stream of a resource inside a zip file.
        Parameters:
        file - The zip file
        resource - Name of the resource
        useAutoDelete - true to return a stream that deletes the file once completely read
        Returns:
        The stream
        Throws:
        Exception - error reading the file
      • getUncompressedSize

        public static long getUncompressedSize​(File file,
                                               String resource)
                                        throws Exception
        Retrieves the real size of a resource inside a zip
        Parameters:
        file - The zip file
        resource - The name of the resource
        Returns:
        The uncompressed size expressed in bytes
        Throws:
        Exception - error reading the file
      • writeZip

        public static long writeZip​(InputStream stream,
                                    String resource,
                                    File dest,
                                    int compressionLevel)
                             throws Exception
        Writes the stream of a resource into a zip file
        Parameters:
        stream - The input stream (it will be closed at the end)
        resource - The name of the resource inside the zip
        dest - The destination file
        compressionLevel - level of compression (between 0 and 9)
        Returns:
        the uncompressed size of the resource
        Throws:
        Exception - error reading the stream
      • writeZip

        public static long writeZip​(File src,
                                    String resource,
                                    File dest,
                                    int compressionLevel)
                             throws Exception
        Writes a resource into a zip file
        Parameters:
        src - The input file
        resource - The name of the resource inside the zip
        dest - The destination file
        compressionLevel - level of compression (between 0 and 9)
        Returns:
        the uncompressed size of the resource
        Throws:
        Exception - error reading the source or writing the destination