code: public void encryptStream(InputStream clearInputStream, OutputStream encryptedOutputStream) throws IOException, MissingParameterException {
  
  		byte[] clearBytes = IOUtils.toByteArray(clearInputStream);
  
  		byte[] cipherBytes = encryptionProvider.encrypt(clearBytes);
  
  		//encryptedOutputStream = new ByteArrayOutputStream(1000);
  
  		encryptedOutputStream.write(cipherBytes);
  
  		encryptedOutputStream.flush();
  		
  		encryptedOutputStream.close();
  		
  	}
docs: Encrypt the contents of an input stream and write the encrypted data to
  the output stream.
  
  @param clearInputStream
  Input stream containing the data to be encrypted.
  @param encryptedOutputStream
  Output stream which the encrypted data will be written to.
  @throws IOException
  @throws MissingParameterException