org.apache.hc.client5.http.entity.mime

## 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:
  `MultipartEntityBuilder`

### Constructor Summary

Constructors
Constructor and Description
`StringBody(String text, org.apache.hc.core5.http.ContentType contentType)`

### Method Summary

Methods
`long` `getContentLength()` Returns the body descriptors content-length.
`String` `getFilename()`
`Reader` `getReader()`
`void` `writeTo(OutputStream out)`

### Methods inherited from class org.apache.hc.client5.http.entity.mime.AbstractContentBody

`getCharset, getContentType, getMediaType, getMimeType, getSubType`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### StringBody

    public StringBody(String text,
              org.apache.hc.core5.http.ContentType contentType)

Since:
  4.3

### Method Detail

#### 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()