mimebodypart.html

来自「SUN的JAVA MAIL API」· HTML 代码 · 共 1,410 行 · 第 1/5 页

HTML
1,410
字号
 to obtain the requisite header field.<DD><DL>
<DT><B>Specified by: </B><DD><A HREF="../../../javax/mail/internet/MimePart.html#getContentLanguage()">getContentLanguage</A> in interface <A HREF="../../../javax/mail/internet/MimePart.html">MimePart</A></DL>
</DD>
</DL>
<HR>

<A NAME="setContentLanguage(java.lang.String[])"><!-- --></A><H3>
setContentLanguage</H3>
<PRE>
public void <B>setContentLanguage</B>(java.lang.String[]&nbsp;languages)
                        throws <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Set the Content-Language header of this MimePart. The
 Content-Language header is defined by RFC 1766.<DD><DL>
<DT><B>Specified by: </B><DD><A HREF="../../../javax/mail/internet/MimePart.html#setContentLanguage(java.lang.String[])">setContentLanguage</A> in interface <A HREF="../../../javax/mail/internet/MimePart.html">MimePart</A><DT><B>Parameters:</B><DD><CODE>languages</CODE> - array of language tags</DL>
</DD>
</DL>
<HR>

<A NAME="getDescription()"><!-- --></A><H3>
getDescription</H3>
<PRE>
public java.lang.String <B>getDescription</B>()
                                throws <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Returns the "Content-Description" header field of this body part.
 This typically associates some descriptive information with 
 this part. Returns null if this field is unavailable or its
 value is absent. <p>

 If the Content-Description field is encoded as per RFC 2047,
 it is decoded and converted into Unicode. If the decoding or 
 conversion fails, the raw data is returned as is. <p>

 This implementation uses <code>getHeader(name)</code>
 to obtain the requisite header field.<DD><DL>
<DT><B>Returns:</B><DD>content description</DL>
</DD>
</DL>
<HR>

<A NAME="setDescription(java.lang.String)"><!-- --></A><H3>
setDescription</H3>
<PRE>
public void <B>setDescription</B>(java.lang.String&nbsp;description)
                    throws <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Set the "Content-Description" header field for this body part.
 If the description parameter is <code>null</code>, then any 
 existing "Content-Description" fields are removed. <p>

 If the description contains non US-ASCII characters, it will 
 be encoded using the platform's default charset. If the 
 description contains only US-ASCII characters, no encoding 
 is done and it is used as is. <p>

 Note that if the charset encoding process fails, a
 MessagingException is thrown, and an UnsupportedEncodingException
 is included in the chain of nested exceptions within the
 MessagingException.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>description</CODE> - content description<DT><B>Throws:</B><DD><A HREF="../../../javax/mail/IllegalWriteException.html">IllegalWriteException</A> - if the underlying
			implementation does not support modification<DD>IllegalStateException - if this body part is
			obtained from a READ_ONLY folder.<DD>MessagingException. - An
                  UnsupportedEncodingException may be included
                  in the exception chain if the charset
                  conversion fails.</DL>
</DD>
</DL>
<HR>

<A NAME="setDescription(java.lang.String, java.lang.String)"><!-- --></A><H3>
setDescription</H3>
<PRE>
public void <B>setDescription</B>(java.lang.String&nbsp;description,
                           java.lang.String&nbsp;charset)
                    throws <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Set the "Content-Description" header field for this body part.
 If the description parameter is <code>null</code>, then any 
 existing "Content-Description" fields are removed. <p>

 If the description contains non US-ASCII characters, it will 
 be encoded using the specified charset. If the description 
 contains only US-ASCII characters, no encoding  is done and 
 it is used as is. <p>

 Note that if the charset encoding process fails, a
 MessagingException is thrown, and an UnsupportedEncodingException
 is included in the chain of nested exceptions within the
 MessagingException.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>description</CODE> - Description<DD><CODE>charset</CODE> - Charset for encoding<DT><B>Throws:</B><DD><A HREF="../../../javax/mail/IllegalWriteException.html">IllegalWriteException</A> - if the underlying
			implementation does not support modification<DD>IllegalStateException - if this body part is
			obtained from a READ_ONLY folder.<DD>MessagingException. - An
                  UnsupportedEncodingException may be included
                  in the exception chain if the charset
                  conversion fails.</DL>
</DD>
</DL>
<HR>

<A NAME="getFileName()"><!-- --></A><H3>
getFileName</H3>
<PRE>
public java.lang.String <B>getFileName</B>()
                             throws <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Get the filename associated with this body part. <p>

 Returns the value of the "filename" parameter from the
 "Content-Disposition" header field of this body part. If its
 not available, returns the value of the "name" parameter from
 the "Content-Type" header field of this body part.
 Returns <code>null</code> if both are absent.<DD><DL>
<DT><B>Returns:</B><DD>filename</DL>
</DD>
</DL>
<HR>

<A NAME="setFileName(java.lang.String)"><!-- --></A><H3>
setFileName</H3>
<PRE>
public void <B>setFileName</B>(java.lang.String&nbsp;filename)
                 throws <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Set the filename associated with this body part, if possible. <p>

 Sets the "filename" parameter of the "Content-Disposition"
 header field of this body part.<DD><DL>
<DT><B>Throws:</B><DD><A HREF="../../../javax/mail/IllegalWriteException.html">IllegalWriteException</A> - if the underlying
			implementation does not support modification<DD>IllegalStateException - if this body part is
			obtained from a READ_ONLY folder.</DL>
</DD>
</DL>
<HR>

<A NAME="getInputStream()"><!-- --></A><H3>
getInputStream</H3>
<PRE>
public java.io.InputStream <B>getInputStream</B>()
                                   throws java.io.IOException,
                                          <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Return a decoded input stream for this body part's "content". <p>

 This implementation obtains the input stream from the DataHandler.
 That is, it invokes getDataHandler().getInputStream();<DD><DL>
<DT><B>Returns:</B><DD>an InputStream<DT><B>Throws:</B><DD><A HREF="../../../javax/mail/MessagingException.html">MessagingException</A> - &nbsp;<DD>java.io.IOException - this is typically thrown by the
			DataHandler. Refer to the documentation for
			javax.activation.DataHandler for more details.<DT><B>See Also: </B><DD><A HREF="../../../javax/mail/internet/MimeBodyPart.html#getContentStream()"><CODE>getContentStream()</CODE></A>, 
<CODE>DataHandler.getInputStream()</CODE></DL>
</DD>
</DL>
<HR>

<A NAME="getContentStream()"><!-- --></A><H3>
getContentStream</H3>
<PRE>
protected java.io.InputStream <B>getContentStream</B>()
                                        throws <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Produce the raw bytes of the content. This method is used
 when creating a DataHandler object for the content. Subclasses
 that can provide a separate input stream for just the Part
 content might want to override this method. <p><DD><DL>
<DT><B>See Also: </B><DD><A HREF="../../../javax/mail/internet/MimeBodyPart.html#content"><CODE>content</CODE></A>, 
<A HREF="../../../javax/mail/internet/MimeMessage.html#getContentStream()"><CODE>MimeMessage.getContentStream()</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getDataHandler()"><!-- --></A><H3>
getDataHandler</H3>
<PRE>
public javax.activation.DataHandler <B>getDataHandler</B>()
                                            throws <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Return a DataHandler for this body part's content. <p>

 The implementation provided here works just like the
 the implementation in MimeMessage.<DD><DL>
<DT><B>See Also: </B><DD><A HREF="../../../javax/mail/internet/MimeMessage.html#getDataHandler()"><CODE>MimeMessage.getDataHandler()</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getContent()"><!-- --></A><H3>
getContent</H3>
<PRE>
public java.lang.Object <B>getContent</B>()
                            throws java.io.IOException,
                                   <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Return the content as a java object. The type of the object
 returned is of course dependent on the content itself. For 
 example, the native format of a text/plain content is usually
 a String object. The native format for a "multipart"
 content is always a Multipart subclass. For content types that are
 unknown to the DataHandler system, an input stream is returned
 as the content. <p>

 This implementation obtains the content from the DataHandler.
 That is, it invokes getDataHandler().getContent();<DD><DL>
<DT><B>Returns:</B><DD>Object<DT><B>Throws:</B><DD><A HREF="../../../javax/mail/MessagingException.html">MessagingException</A> - &nbsp;<DD>java.io.IOException - this is typically thrown by the
			DataHandler. Refer to the documentation for
			javax.activation.DataHandler for more details.</DL>
</DD>
</DL>
<HR>

<A NAME="setDataHandler(javax.activation.DataHandler)"><!-- --></A><H3>
setDataHandler</H3>
<PRE>
public void <B>setDataHandler</B>(javax.activation.DataHandler&nbsp;dh)
                    throws <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>This method provides the mechanism to set this body part's content.
 The given DataHandler object should wrap the actual content.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>dh</CODE> - The DataHandler for the content<DT><B>Throws:</B><DD><A HREF="../../../javax/mail/IllegalWriteException.html">IllegalWriteException</A> - if the underlying
 			implementation does not support modification<DD>IllegalStateException - if this body part is
			obtained from a READ_ONLY folder.</DL>
</DD>
</DL>
<HR>

<A NAME="setContent(java.lang.Object, java.lang.String)"><!-- --></A><H3>
setContent</H3>
<PRE>
public void <B>setContent</B>(java.lang.Object&nbsp;o,
                       java.lang.String&nbsp;type)
                throws <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>A convenience method for setting this body part's content. <p>

 The content is wrapped in a DataHandler object. Note that a
 DataContentHandler class for the specified type should be
 available to the JavaMail implementation for this to work right.
 That is, to do <code>setContent(foobar, "application/x-foobar")</code>,
 a DataContentHandler for "application/x-foobar" should be installed.
 Refer to the Java Activation Framework for more information.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>o</CODE> - the content object<DD><CODE>type</CODE> - Mime type of the object<DT><B>Throws:</B><DD><A HREF="../../../javax/mail/IllegalWriteException.html">IllegalWriteException</A> - if the underlying
			implementation does not support modification of
			existing values<DD>IllegalStateException - if this body part is
			obtained from a READ_ONLY folder.</DL>
</DD>
</DL>
<HR>

<A NAME="setText(java.lang.String)"><!-- --></A><H3>
setText</H3>
<PRE>
public void <B>setText</B>(java.lang.String&nbsp;text)
             throws <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Convenience method that sets the given String as this
 part's content, with a MIME type of "text/plain". If the
 string contains non US-ASCII characters, it will be encoded
 using the platform's default charset. The charset is also
 used to set the "charset" parameter. <p>

 Note that there may be a performance penalty if
 <code>text</code> is large, since this method may have
 to scan all the characters to determine what charset to
 use. <p>
 If the charset is already known, use the
 setText() version that takes the charset parameter.<DD><DL>
<DT><B>Specified by: </B><DD><A HREF="../../../javax/mail/internet/MimePart.html#setText(java.lang.String)">setText</A> in interface <A HREF="../../../javax/mail/internet/MimePart.html">MimePart</A><DT><B>See Also: </B><DD><A HREF="../../../javax/mail/internet/MimeBodyPart.html#setText(java.lang.String, java.lang.String)"><CODE>setText(String text, String charset)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="setText(java.lang.String, java.lang.String)"><!-- --></A><H3>
setText</H3>
<PRE>
public void <B>setText</B>(java.lang.String&nbsp;text,
                    java.lang.String&nbsp;charset)
             throws <A HREF="../../../javax/mail/MessagingException.html">MessagingException</A></PRE>
<DL>
<DD>Convenience method that sets the given String as this part's
 content, with a MIME type of "text/plain" and the specified
 charset. The given Unicode string will be charset-encoded
 using the specified charset. The charset is also used to set
 the "charset" parameter.<DD><DL>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?