PreencodedMimeBodyPartpublic class PreencodedMimeBodyPart extends MimeBodyPart A MimeBodyPart that handles data that has already been encoded.
This class is useful when constructing a message and attaching
data that has already been encoded (for example, using base64
encoding). The data may have been encoded by the application,
or may have been stored in a file or database in encoded form.
The encoding is supplied when this object is created. The data
is attached to this object in the usual fashion, by using the
setText , setContent , or
setDataHandler methods. |
Fields Summary |
---|
private String | encoding |
Constructors Summary |
---|
public PreencodedMimeBodyPart(String encoding)Create a PreencodedMimeBodyPart that assumes the data is
encoded using the specified encoding. The encoding must
be a MIME supported Content-Transfer-Encoding.
this.encoding = encoding;
|
Methods Summary |
---|
public java.lang.String | getEncoding()Returns the content transfer encoding specified when
this object was created.
return encoding;
| protected void | updateHeaders()Force the Content-Transfer-Encoding header to use
the encoding that was specified when this object was created.
super.updateHeaders();
MimeBodyPart.setEncoding(this, encoding);
| public void | writeTo(java.io.OutputStream os)Output the body part as an RFC 822 format stream.
// see if we already have a LOS
LineOutputStream los = null;
if (os instanceof LineOutputStream) {
los = (LineOutputStream) os;
} else {
los = new LineOutputStream(os);
}
// First, write out the header
Enumeration hdrLines = getAllHeaderLines();
while (hdrLines.hasMoreElements())
los.writeln((String)hdrLines.nextElement());
// The CRLF separator between header and content
los.writeln();
// Finally, the content, already encoded.
getDataHandler().writeTo(os);
os.flush();
|
|