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
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
content
-
Constructor Summary
Constructors Constructor Description StringBody(java.lang.String text, org.apache.hc.core5.http.ContentType contentType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getContentLength()
Returns the body descriptors content-length.java.lang.String
getFilename()
java.io.Reader
getReader()
void
writeTo(java.io.OutputStream out)
-
Methods inherited from class org.apache.hc.client5.http.entity.mime.AbstractContentBody
getCharset, getContentType, getMediaType, getMimeType, getSubType
-
-
-
-
Method Detail
-
getReader
public java.io.Reader getReader()
-
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.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 java.lang.String getFilename()
-
-