Class StringBody
- java.lang.Object
 - 
- org.apache.http.entity.mime.content.AbstractContentBody
 - 
- org.apache.http.entity.mime.content.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 Description StringBody(java.lang.String text)Deprecated.(4.3) useStringBody(String, ContentType)orMultipartEntityBuilderStringBody(java.lang.String text, java.lang.String mimeType, java.nio.charset.Charset charset)Deprecated.(4.3) useStringBody(String, ContentType)orMultipartEntityBuilderStringBody(java.lang.String text, java.nio.charset.Charset charset)Deprecated.(4.3) useStringBody(String, ContentType)orMultipartEntityBuilderStringBody(java.lang.String text, ContentType contentType) 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StringBodycreate(java.lang.String text)Deprecated.(4.3) useStringBody(String, ContentType)orMultipartEntityBuilderstatic StringBodycreate(java.lang.String text, java.lang.String mimeType, java.nio.charset.Charset charset)Deprecated.(4.3) useStringBody(String, ContentType)orMultipartEntityBuilderstatic StringBodycreate(java.lang.String text, java.nio.charset.Charset charset)Deprecated.(4.3) useStringBody(String, ContentType)orMultipartEntityBuilderlonggetContentLength()Returns the body descriptors content-length.java.lang.StringgetFilename()java.io.ReadergetReader()java.lang.StringgetTransferEncoding()Returns the body descriptors transfer encoding.voidwriteTo(java.io.OutputStream out)- 
Methods inherited from class org.apache.http.entity.mime.content.AbstractContentBody
getCharset, getContentType, getMediaType, getMimeType, getSubType 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
StringBody
@Deprecated public StringBody(java.lang.String text, java.lang.String mimeType, java.nio.charset.Charset charset) throws java.io.UnsupportedEncodingExceptionDeprecated.(4.3) useStringBody(String, ContentType)orMultipartEntityBuilderCreate a StringBody from the specified text, MIME type and character set.- Parameters:
 text- to be used for the body, notnullmimeType- the MIME type, notnullcharset- the character set, may benull, in which case the US-ASCII charset is used- Throws:
 java.io.UnsupportedEncodingExceptionjava.lang.IllegalArgumentException- if thetextparameter is null
 
- 
StringBody
@Deprecated public StringBody(java.lang.String text, java.nio.charset.Charset charset) throws java.io.UnsupportedEncodingExceptionDeprecated.(4.3) useStringBody(String, ContentType)orMultipartEntityBuilderCreate 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, notnullcharset- the character set, may benull, in which case the US-ASCII charset is used- Throws:
 java.io.UnsupportedEncodingExceptionjava.lang.IllegalArgumentException- if thetextparameter is null
 
- 
StringBody
@Deprecated public StringBody(java.lang.String text) throws java.io.UnsupportedEncodingExceptionDeprecated.(4.3) useStringBody(String, ContentType)orMultipartEntityBuilderCreate 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:
 java.io.UnsupportedEncodingExceptionjava.lang.IllegalArgumentException- if thetextparameter is null
 
- 
StringBody
public StringBody(java.lang.String text, ContentType contentType)- Since:
 - 4.3
 
 
 - 
 
- 
Method Detail
- 
create
@Deprecated public static StringBody create(java.lang.String text, java.lang.String mimeType, java.nio.charset.Charset charset) throws java.lang.IllegalArgumentException
Deprecated.(4.3) useStringBody(String, ContentType)orMultipartEntityBuilder- Throws:
 java.lang.IllegalArgumentException- Since:
 - 4.1
 
 
- 
create
@Deprecated public static StringBody create(java.lang.String text, java.nio.charset.Charset charset) throws java.lang.IllegalArgumentException
Deprecated.(4.3) useStringBody(String, ContentType)orMultipartEntityBuilder- Throws:
 java.lang.IllegalArgumentException- Since:
 - 4.1
 
 
- 
create
@Deprecated public static StringBody create(java.lang.String text) throws java.lang.IllegalArgumentException
Deprecated.(4.3) useStringBody(String, ContentType)orMultipartEntityBuilder- Throws:
 java.lang.IllegalArgumentException- Since:
 - 4.1
 
 
- 
getReader
public java.io.Reader getReader()
 
- 
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOException- Throws:
 java.io.IOException
 
- 
getTransferEncoding
public java.lang.String getTransferEncoding()
Description copied from interface:ContentDescriptorReturns 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:ContentDescriptorReturns 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()
 
 - 
 
 -