Class StringBody
java.lang.Object
org.apache.http.entity.mime.content.AbstractContentBody
org.apache.http.entity.mime.content.StringBody
- All Implemented Interfaces:
ContentBody
,ContentDescriptor
Text body part backed by a byte array.
- Since:
- 4.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionStringBody
(String text) Deprecated.StringBody
(String text, String mimeType, Charset charset) Deprecated.(4.3) useStringBody(String, ContentType)
orMultipartEntityBuilder
StringBody
(String text, Charset charset) Deprecated.(4.3) useStringBody(String, ContentType)
orMultipartEntityBuilder
StringBody
(String text, org.apache.http.entity.ContentType contentType) -
Method Summary
Modifier and TypeMethodDescriptionstatic StringBody
Deprecated.(4.3) useStringBody(String, ContentType)
orMultipartEntityBuilder
static StringBody
Deprecated.(4.3) useStringBody(String, ContentType)
orMultipartEntityBuilder
static StringBody
Deprecated.(4.3) useStringBody(String, ContentType)
orMultipartEntityBuilder
long
Returns the body descriptors content-length.Returns the body descriptors transfer encoding.void
writeTo
(OutputStream out) Methods inherited from class org.apache.http.entity.mime.content.AbstractContentBody
getCharset, getContentType, getMediaType, getMimeType, getSubType
-
Constructor Details
-
StringBody
@Deprecated public StringBody(String text, String mimeType, Charset charset) throws UnsupportedEncodingException Deprecated.(4.3) useStringBody(String, ContentType)
orMultipartEntityBuilder
Create a StringBody from the specified text, MIME type and character set.- Parameters:
text
- to be used for the body, notnull
mimeType
- the MIME type, notnull
charset
- the character set, may benull
, in which case the US-ASCII charset is used- Throws:
UnsupportedEncodingException
IllegalArgumentException
- if thetext
parameter is null
-
StringBody
Deprecated.(4.3) useStringBody(String, ContentType)
orMultipartEntityBuilder
Create a StringBody from the specified text and character set. The MIME type is set to "text/plain".- Parameters:
text
- to be used for the body, notnull
charset
- the character set, may benull
, in which case the US-ASCII charset is used- Throws:
UnsupportedEncodingException
IllegalArgumentException
- if thetext
parameter is null
-
StringBody
Deprecated.(4.3) useStringBody(String, ContentType)
orMultipartEntityBuilder
Create a StringBody from the specified text. The MIME type is set to "text/plain". The ASCII charset is used.- Parameters:
text
- to be used for the body, notnull
- Throws:
UnsupportedEncodingException
IllegalArgumentException
- if thetext
parameter is null
-
StringBody
- Since:
- 4.3
-
-
Method Details
-
create
@Deprecated public static StringBody create(String text, String mimeType, Charset charset) throws IllegalArgumentException Deprecated.(4.3) useStringBody(String, ContentType)
orMultipartEntityBuilder
- Throws:
IllegalArgumentException
- Since:
- 4.1
-
create
@Deprecated public static StringBody create(String text, Charset charset) throws IllegalArgumentException Deprecated.(4.3) useStringBody(String, ContentType)
orMultipartEntityBuilder
- Throws:
IllegalArgumentException
- Since:
- 4.1
-
create
Deprecated.(4.3) useStringBody(String, ContentType)
orMultipartEntityBuilder
- Throws:
IllegalArgumentException
- Since:
- 4.1
-
getReader
-
writeTo
- Throws:
IOException
-
getTransferEncoding
Description copied from interface:ContentDescriptor
Returns the body descriptors transfer encoding.- Returns:
- The transfer encoding. Must not be null, but "7bit", if no transfer-encoding was specified.
-
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
-
StringBody(String, ContentType)
orMultipartEntityBuilder