FileDocCategorySizeDatePackage
StringEntity.javaAPI DocAndroid 1.5 API3369Wed May 06 22:41:10 BST 2009org.apache.http.entity

StringEntity

public class StringEntity extends AbstractHttpEntity implements Cloneable
An entity whose content is retrieved from a string.
author
Oleg Kalnichevski
version
$Revision: 618367 $
since
4.0

Fields Summary
protected final byte[]
content
Constructors Summary
public StringEntity(String s, String charset)

        super();
        if (s == null) {
            throw new IllegalArgumentException("Source string may not be null");
        }
        if (charset == null) {
            charset = HTTP.DEFAULT_CONTENT_CHARSET;
        }
        this.content = s.getBytes(charset);
        setContentType(HTTP.PLAIN_TEXT_TYPE + HTTP.CHARSET_PARAM + charset);
    
public StringEntity(String s)

        this(s, null);
    
Methods Summary
public java.lang.Objectclone()

        return super.clone();
    
public java.io.InputStreamgetContent()

        return new ByteArrayInputStream(this.content);
    
public longgetContentLength()

        return this.content.length;
    
public booleanisRepeatable()

        return true;
    
public booleanisStreaming()
Tells that this entity is not streaming.

return
false

        return false;
    
public voidwriteTo(java.io.OutputStream outstream)

        if (outstream == null) {
            throw new IllegalArgumentException("Output stream may not be null");
        }
        outstream.write(this.content);
        outstream.flush();