Class RFileCipherOutputStream

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

    public class RFileCipherOutputStream
    extends CipherOutputStream
    This class extends CipherOutputStream to include a way to track the number of bytes that have been encrypted by the stream. The write method also includes a mechanism to stop writing and throw an exception if exceeding a maximum number of bytes is attempted.
    • Constructor Detail

      • RFileCipherOutputStream

        public RFileCipherOutputStream​(OutputStream os,
                                       Cipher c)
        Constructs a RFileCipherOutputStream
        Parameters:
        os - the OutputStream object
        c - an initialized Cipher object
    • Method Detail

      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws IOException
        Override of CipherOutputStream's write to count the number of bytes that have been encrypted. This method now throws an exception if an attempt to write bytes beyond a maximum is made.
        Overrides:
        write in class CipherOutputStream
        Throws:
        IOException
      • write

        public void write​(int b)
                   throws IOException
        Override of CipherOutputStream's write for a single byte to count it. This method now throws an exception if an attempt to write bytes beyond a maximum is made.
        Overrides:
        write in class CipherOutputStream
        Throws:
        IOException