Package jakarta.mail.internet
Class PreencodedMimeBodyPart
- java.lang.Object
-
- jakarta.mail.BodyPart
-
- jakarta.mail.internet.MimeBodyPart
-
- jakarta.mail.internet.PreencodedMimeBodyPart
-
public 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 thesetText,setContent, orsetDataHandlermethods.- Since:
- JavaMail 1.4
-
-
Field Summary
-
Fields inherited from class jakarta.mail.internet.MimeBodyPart
cachedContent, content, contentStream, dh, headers
-
Fields inherited from class jakarta.mail.BodyPart
parent, streamProvider
-
Fields inherited from interface jakarta.mail.Part
ATTACHMENT, INLINE
-
-
Constructor Summary
Constructors Constructor Description PreencodedMimeBodyPart(String encoding)Create a PreencodedMimeBodyPart that assumes the data is encoded using the specified encoding.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetEncoding()Returns the content transfer encoding specified when this object was created.protected voidupdateHeaders()Force theContent-Transfer-Encodingheader to use the encoding that was specified when this object was created.voidwriteTo(OutputStream os)Output the body part as an RFC 822 format stream.-
Methods inherited from class jakarta.mail.internet.MimeBodyPart
addHeader, addHeaderLine, attachFile, attachFile, attachFile, attachFile, getAllHeaderLines, getAllHeaders, getContent, getContentID, getContentLanguage, getContentMD5, getContentStream, getContentType, getDataHandler, getDescription, getDisposition, getFileName, getHeader, getHeader, getInputStream, getLineCount, getMatchingHeaderLines, getMatchingHeaders, getNonMatchingHeaderLines, getNonMatchingHeaders, getRawInputStream, getSize, isMimeType, removeHeader, saveFile, saveFile, setContent, setContent, setContentID, setContentLanguage, setContentMD5, setDataHandler, setDescription, setDescription, setDisposition, setFileName, setHeader, setText, setText, setText
-
-
-
-
Constructor Detail
-
PreencodedMimeBodyPart
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.- Parameters:
encoding- the Content-Transfer-Encoding
-
-
Method Detail
-
getEncoding
public String getEncoding() throws MessagingException
Returns the content transfer encoding specified when this object was created.- Specified by:
getEncodingin interfaceMimePart- Overrides:
getEncodingin classMimeBodyPart- Returns:
- content-transfer-encoding
- Throws:
MessagingException- for failures- See Also:
MimeBodyPart.headers
-
writeTo
public void writeTo(OutputStream os) throws IOException, MessagingException
Output the body part as an RFC 822 format stream.- Specified by:
writeToin interfacePart- Overrides:
writeToin classMimeBodyPart- Parameters:
os- the stream to write to- Throws:
IOException- if an error occurs writing to the stream or if an error is generated by the jakarta.activation layer.MessagingException- for other failures- See Also:
DataHandler.writeTo(java.io.OutputStream)
-
updateHeaders
protected void updateHeaders() throws MessagingExceptionForce theContent-Transfer-Encodingheader to use the encoding that was specified when this object was created.- Overrides:
updateHeadersin classMimeBodyPart- Throws:
MessagingException- for failures
-
-