org.apache.http.entity.mime.content
Class StringBody

java.lang.Object
  extended by org.apache.http.entity.mime.content.AbstractContentBody
      extended by 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
StringBody(String text)
          Deprecated. (4.3) use StringBody(String, ContentType) or MultipartEntityBuilder
StringBody(String text, Charset charset)
          Deprecated. (4.3) use StringBody(String, ContentType) or MultipartEntityBuilder
StringBody(String text, ContentType contentType)
           
StringBody(String text, String mimeType, Charset charset)
          Deprecated. (4.3) use StringBody(String, ContentType) or MultipartEntityBuilder
 
Method Summary
static StringBody create(String text)
          Deprecated. (4.3) use StringBody(String, ContentType) or MultipartEntityBuilder
static StringBody create(String text, Charset charset)
          Deprecated. (4.3) use StringBody(String, ContentType) or MultipartEntityBuilder
static StringBody create(String text, String mimeType, Charset charset)
          Deprecated. (4.3) use StringBody(String, ContentType) or MultipartEntityBuilder
 long getContentLength()
          Returns the body descriptors content-length.
 String getFilename()
           
 Reader getReader()
           
 String getTransferEncoding()
          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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringBody

@Deprecated
public StringBody(String text,
                             String mimeType,
                             Charset charset)
           throws UnsupportedEncodingException
Deprecated. (4.3) use StringBody(String, ContentType) or MultipartEntityBuilder

Create a StringBody from the specified text, MIME type and character set.

Parameters:
text - to be used for the body, not null
mimeType - the MIME type, not null
charset - the character set, may be null, in which case the US-ASCII charset is used
Throws:
UnsupportedEncodingException
IllegalArgumentException - if the text parameter is null

StringBody

@Deprecated
public StringBody(String text,
                             Charset charset)
           throws UnsupportedEncodingException
Deprecated. (4.3) use StringBody(String, ContentType) or MultipartEntityBuilder

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, not null
charset - the character set, may be null, in which case the US-ASCII charset is used
Throws:
UnsupportedEncodingException
IllegalArgumentException - if the text parameter is null

StringBody

@Deprecated
public StringBody(String text)
           throws UnsupportedEncodingException
Deprecated. (4.3) use StringBody(String, ContentType) or MultipartEntityBuilder

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, not null
Throws:
UnsupportedEncodingException
IllegalArgumentException - if the text parameter is null

StringBody

public StringBody(String text,
                  ContentType contentType)
Since:
4.3
Method Detail

create

@Deprecated
public static StringBody create(String text,
                                           String mimeType,
                                           Charset charset)
                         throws IllegalArgumentException
Deprecated. (4.3) use StringBody(String, ContentType) or MultipartEntityBuilder

Throws:
IllegalArgumentException
Since:
4.1

create

@Deprecated
public static StringBody create(String text,
                                           Charset charset)
                         throws IllegalArgumentException
Deprecated. (4.3) use StringBody(String, ContentType) or MultipartEntityBuilder

Throws:
IllegalArgumentException
Since:
4.1

create

@Deprecated
public static StringBody create(String text)
                         throws IllegalArgumentException
Deprecated. (4.3) use StringBody(String, ContentType) or MultipartEntityBuilder

Throws:
IllegalArgumentException
Since:
4.1

getReader

public Reader getReader()

writeTo

public void writeTo(OutputStream out)
             throws IOException
Throws:
IOException

getTransferEncoding

public String 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

public String getFilename()


Copyright © 1999–2017 The Apache Software Foundation. All rights reserved.