public class StringBody extends AbstractContentBody
| Constructor and Description |
|---|
StringBody(String text)
Create a StringBody from the specified text.
|
StringBody(String text,
Charset charset)
Create a StringBody from the specified text and character set.
|
StringBody(String text,
String mimeType,
Charset charset)
Create a StringBody from the specified text, mime type and character set.
|
| Modifier and Type | Method and Description |
|---|---|
static StringBody |
create(String text) |
static StringBody |
create(String text,
Charset charset) |
static StringBody |
create(String text,
String mimeType,
Charset charset) |
String |
getCharset()
The body descriptors character set, defaulted appropriately for the MIME type.
|
long |
getContentLength()
Returns the body descriptors content-length.
|
String |
getFilename() |
Reader |
getReader() |
String |
getTransferEncoding()
Returns the body descriptors transfer encoding.
|
void |
writeTo(OutputStream out) |
getMediaType, getMimeType, getSubTypepublic StringBody(String text, String mimeType, Charset charset) throws UnsupportedEncodingException
text - to be used for the body, not nullmimeType - the mime type, not nullcharset - the character set, may be null, in which case the US-ASCII charset is usedUnsupportedEncodingExceptionIllegalArgumentException - if the text parameter is nullpublic StringBody(String text, Charset charset) throws UnsupportedEncodingException
text - to be used for the body, not nullcharset - the character set, may be null, in which case the US-ASCII charset is usedUnsupportedEncodingExceptionIllegalArgumentException - if the text parameter is nullpublic StringBody(String text) throws UnsupportedEncodingException
text - to be used for the body, not nullUnsupportedEncodingExceptionIllegalArgumentException - if the text parameter is nullpublic static StringBody create(String text, String mimeType, Charset charset) throws IllegalArgumentException
IllegalArgumentExceptionpublic static StringBody create(String text, Charset charset) throws IllegalArgumentException
IllegalArgumentExceptionpublic static StringBody create(String text) throws IllegalArgumentException
IllegalArgumentExceptionpublic Reader getReader()
public void writeTo(OutputStream out) throws IOException
IOExceptionpublic String getTransferEncoding()
ContentDescriptorpublic String getCharset()
ContentDescriptorThe body descriptors character set, defaulted appropriately for the MIME type.
For TEXT types, this will be defaulted to us-ascii.
For other types, when the charset parameter is missing this property will be null.
TEXT types, when unset will
be set to default us-ascii. For other types, when unset,
null will be returned.public long getContentLength()
ContentDescriptorpublic String getFilename()
Copyright © 1999–2013 The Apache Software Foundation. All rights reserved.