Class Base64InputStreamConsumer

java.lang.Object
com.atlassian.jira.util.Base64InputStreamConsumer
All Implemented Interfaces:
Consumer<InputStream>

public class Base64InputStreamConsumer extends Object implements Consumer<InputStream>
Basic slurp implementation of an InputStream Consumer which provides Base64 encoded output. Note that this reads the whole input into memory and should not be used for data that may grow big.
Since:
v4.0
  • Constructor Details

    • Base64InputStreamConsumer

      public Base64InputStreamConsumer(boolean chunked)
      Creates this encoder. Set chunked to true if you want a 72 character formatted ("chunked") String or false if you don't need formatting.
      Parameters:
      chunked - whether you want a chunked Base64 encoded output.
  • Method Details

    • consume

      public void consume(@Nonnull InputStream element)
      Description copied from interface: Consumer
      Consume the product.
      Specified by:
      consume in interface Consumer<InputStream>
      Parameters:
      element - must not be null
    • getEncoded

      public String getEncoded()
      Gives the Base64 encoded String only if the consume method ran without exception. Otherwise returns the empty String.
      Returns:
      the empty String or the base64 encoded content of the InputStream.