Class ByteContent

  • All Implemented Interfaces:
    Content

    public class ByteContent
    extends AbstractContent
    Content stored in a byte array.
    • Constructor Detail

      • ByteContent

        public ByteContent​(byte[] content)
        Default constructor accepts a byte array.
        Parameters:
        content - the actual content. This should not be null.
      • ByteContent

        public ByteContent​(Content content)
                    throws java.io.IOException
        Convert any Content into ByteContent. Any content is read from the InputStream into a new underlying byte array.
        Parameters:
        content - existing content to read.
        Throws:
        java.io.IOException - when errors occur reading content.
    • Method Detail

      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        Description copied from interface: Content
        The content bytes as a stream.
        Returns:
        a ByteArrayInputStream for the wrapped content.
        Throws:
        java.io.IOException - if an error occurs while creating the stream.
      • getByteArray

        public byte[] getByteArray()
        Returns:
        the wrapped byte array.
      • close

        public void close()
        Free any resources associated with this content.