Package com.mku.salmonfs.streams
Class AesFileInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.mku.salmonfs.streams.AesFileInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class AesFileInputStream extends java.io.InputStreamInputStream wrapper for seeking and reading an encrypted AesFile. This class provides a seekable source with parallel streams and cached buffers for performance.
-
-
Constructor Summary
Constructors Constructor Description AesFileInputStream(AesFile aesFile, int buffersCount, int bufferSize, int threads, int backOffset)Instantiate a seekable stream from an encrypted file source
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the stream and associated backed streams and clear buffers.longgetLength()Get the size of the stream.longgetPositionEnd()Get the end position for the stream.longgetPositionStart()Get the start position for the stream.intread()Read a byte from the stream.intread(byte[] buffer, int offset, int count)Reads and decrypts the contents of an encrypted filevoidreset()Reset the stream.voidsetPositionEnd(long pos)Set the end position for the stream.voidsetPositionStart(long pos)Set the start position for the stream.longskip(long bytes)Skip a number of bytes.
-
-
-
Constructor Detail
-
AesFileInputStream
public AesFileInputStream(AesFile aesFile, int buffersCount, int bufferSize, int threads, int backOffset) throws java.io.IOException
Instantiate a seekable stream from an encrypted file source- Parameters:
aesFile- 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:
java.io.IOException- Thrown if there is an IO error.
-
-
Method Detail
-
skip
public long skip(long bytes)
Skip a number of bytes.- Overrides:
skipin classjava.io.InputStream- Parameters:
bytes- the number of bytes to be skipped.- Returns:
- The byte skipped
-
reset
public void reset()
Reset the stream.- Overrides:
resetin classjava.io.InputStream
-
read
public int read() throws java.io.IOExceptionRead a byte from the stream.- Specified by:
readin classjava.io.InputStream- Returns:
- The bytes read
- Throws:
java.io.IOException- Thrown if there is an IO error.
-
read
public int read(byte[] buffer, int offset, int count) throws java.io.IOExceptionReads and decrypts the contents of an encrypted file- Overrides:
readin classjava.io.InputStream- Parameters:
buffer- The buffer that will store the decrypted contentsoffset- The position on the buffer that the decrypted data will startcount- The length of the data requested- Throws:
java.io.IOException
-
getLength
public long getLength()
Get the size of the stream.- Returns:
- The size
-
getPositionStart
public long getPositionStart()
Get the start position for the stream.- Returns:
- The start position.
-
setPositionStart
public void setPositionStart(long pos)
Set the start position for the stream.- Parameters:
pos- The start position.
-
getPositionEnd
public long getPositionEnd()
Get the end position for the stream.- Returns:
- The end position.
-
setPositionEnd
public void setPositionEnd(long pos)
Set the end position for the stream.- Parameters:
pos- The end position.
-
close
public void close() throws java.io.IOExceptionClose the stream and associated backed streams and clear buffers.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException- Thrown if there is an IO error.
-
-