class StringTextBody extends TextBody
String.| Modifier and Type | Field and Description |
|---|---|
private java.nio.charset.Charset |
charset |
private java.lang.String |
text |
| Constructor and Description |
|---|
StringTextBody(java.lang.String text,
java.nio.charset.Charset charset) |
| Modifier and Type | Method and Description |
|---|---|
StringTextBody |
copy()
Returns a copy of this
SingleBody (optional operation). |
java.io.InputStream |
getInputStream()
Gets a
InputStream which reads the bytes of the body. |
java.lang.String |
getMimeCharset()
Returns the MIME charset of this text body.
|
java.io.Reader |
getReader()
Gets a
Reader which may be used to read out the contents
of this body. |
void |
writeTo(java.io.OutputStream out)
Writes this single body to the given stream.
|
dispose, getParent, setParentprivate final java.lang.String text
private final java.nio.charset.Charset charset
public StringTextBody(java.lang.String text,
java.nio.charset.Charset charset)
public java.lang.String getMimeCharset()
TextBodygetMimeCharset in class TextBodypublic java.io.InputStream getInputStream()
throws java.io.IOException
SingleBodyInputStream which reads the bytes of the body.getInputStream in class SingleBodyjava.io.IOException - on I/O errors.public java.io.Reader getReader()
throws java.io.IOException
TextBodyReader which may be used to read out the contents
of this body.public void writeTo(java.io.OutputStream out)
throws java.io.IOException
SingleBodySingleBody.getInputStream() to the specified output
stream. May be overwritten by a subclass to improve performance.writeTo in class SingleBodyout - the stream to write to.java.io.IOException - in case of an I/O errorpublic StringTextBody copy()
SingleBodySingleBody (optional operation).
The general contract of this method is as follows:
SingleBody.getParent() on the copy returns null.
That means that the copy is detached from the parent entity of this
SingleBody. The copy may get attached to a different
entity later on.SingleBody.
This implementation always throws an
UnsupportedOperationException.
copy in class SingleBodySingleBody.