EncryptedOutputStream public class EncryptedOutputStream extends FilterOutputStream An OutputStream that supports encryption. This class encapsulates a StreamCipher or BlockCipher as an OutputStream. You set up your cipher, pass it and the underlying stream to the EncryptedOutputStream constructor, and then write your cleartext to this stream. It gets encrypted and sent to the underlying stream.
Decryption is done by an EncryptedInputStream.
When used with a StreamCipher, no output protocol is necessary, each byte of cleartext turns into one byte of ciphertext. When used with a BlockCipher it's more complicated. Each block of cleartext is encrypted into a block of ciphertext, sent to the stream, and then one more byte is sent that says how many bytes in the block are valid. Generally the bytecount will be equal to the block size, but it can be less if the stream gets flushed or closed on a partial block. Fetch the software.