Class StringBody

java.lang.Object
org.apache.hc.client5.http.entity.mime.AbstractContentBody
org.apache.hc.client5.http.entity.mime.StringBody
All Implemented Interfaces:
ContentBody, ContentDescriptor

public class StringBody extends AbstractContentBody
Text body part backed by a byte array.
Since:
4.0
See Also:
  • Field Details

    • content

      private final byte[] content
  • Constructor Details

    • StringBody

      public StringBody(String text, org.apache.hc.core5.http.ContentType contentType)
      Since:
      4.3
  • Method Details

    • getReader

      public Reader getReader()
    • writeTo

      public void writeTo(OutputStream out) throws IOException
      Throws:
      IOException
    • getContentLength

      public long getContentLength()
      Description copied from interface: ContentDescriptor
      Returns the body descriptors content-length.
      Returns:
      Content length, if known, or -1, to indicate the absence of a content-length header.
    • getFilename

      public String getFilename()