Class ByteArrayEntity

java.lang.Object
org.apache.http.entity.AbstractHttpEntity
org.apache.http.entity.ByteArrayEntity
All Implemented Interfaces:
Cloneable, HttpEntity

public class ByteArrayEntity
extends AbstractHttpEntity
implements Cloneable
An entity whose content is retrieved from a byte array.
Since:
4.0
Version:
$Revision: 604625 $
Author:
Oleg Kalnichevski
  • Field Details

    • content

      protected final byte[] content
  • Constructor Details

    • ByteArrayEntity

      public ByteArrayEntity​(byte[] b)
  • Method Details

    • isRepeatable

      public boolean isRepeatable()
      Description copied from interface: HttpEntity
      Tells if the entity is capable to produce its data more than once. A repeatable entity's getContent() and writeTo(OutputStream) methods can be called more than once whereas a non-repeatable entity's can not.
      Specified by:
      isRepeatable in interface HttpEntity
      Returns:
      true if the entity is repeatable, false otherwise.
    • getContentLength

      public long getContentLength()
      Description copied from interface: HttpEntity
      Tells the length of the content, if known.
      Specified by:
      getContentLength in interface HttpEntity
      Returns:
      the number of bytes of the content, or a negative number if unknown. If the content length is known but exceeds Long.MAX_VALUE, a negative number is returned.
    • getContent

      public InputStream getContent()
      Description copied from interface: HttpEntity
      Creates a new InputStream object of the entity. It is a programming error to return the same InputStream object more than once. Entities that are not repeatable will throw an exception if this method is called multiple times.
      Specified by:
      getContent in interface HttpEntity
      Returns:
      a new input stream that returns the entity data.
    • writeTo

      public void writeTo​(OutputStream outstream) throws IOException
      Description copied from interface: HttpEntity
      Writes the entity content to the output stream.
      Specified by:
      writeTo in interface HttpEntity
      Parameters:
      outstream - the output stream to write entity content to
      Throws:
      IOException - if an I/O error occurs
    • isStreaming

      public boolean isStreaming()
      Tells that this entity is not streaming.
      Specified by:
      isStreaming in interface HttpEntity
      Returns:
      false
    • clone

      public Object clone() throws CloneNotSupportedException
      Description copied from class: Object
      Creates and returns a copy of this Object. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should call super.clone() to create the new instance and then create deep copies of the nested, mutable objects.
      Overrides:
      clone in class Object
      Returns:
      a copy of this object.
      Throws:
      CloneNotSupportedException - if this object's class does not implement the Cloneable interface.