Class AesFileInputStream

java.lang.Object
java.io.InputStream
com.mku.streams.InputStreamWrapper
com.mku.salmonfs.streams.AesFileInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class AesFileInputStream extends InputStreamWrapper
InputStream wrapper for seeking and reading an encrypted AesFile. This class provides a seekable source with parallel streams and cached buffers for performance.
  • Constructor Details

    • AesFileInputStream

      public AesFileInputStream(AesFile salmonFile) throws IOException
      Instantiate a seekable stream from an encrypted file source
      Parameters:
      salmonFile - The source file.
      Throws:
      IOException - Thrown if there is an IO error.
    • AesFileInputStream

      public AesFileInputStream(AesFile salmonFile, int buffersCount, int bufferSize, int threads, int backOffset) throws IOException
      Instantiate a seekable stream from an encrypted file source
      Parameters:
      salmonFile - The source file.
      buffersCount - Number of buffers to use.
      bufferSize - The length of each buffer.
      threads - The number of threads/streams to source the file in parallel.
      backOffset - The back offset.
      Throws:
      IOException - Thrown if there is an IO error.
  • Method Details

    • fillBuffer

      protected int fillBuffer(Buffer cacheBuffer, long startPosition, int length) throws IOException
      Fills a cache buffer with the decrypted data from the encrypted source file.
      Overrides:
      fillBuffer in class InputStreamWrapper
      Parameters:
      cacheBuffer - The cache buffer that will store the decrypted contents
      startPosition - The start position
      length - The length of the data requested
      Returns:
      The number of bytes read
      Throws:
      IOException - When IO error occurs
    • close

      public void close() throws IOException
      Close the stream and associated backed streams and clear buffers.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStreamWrapper
      Throws:
      IOException - Thrown if there is an IO error.