mimeutility.html
来自「j2ee帮助文档软件设计/软件工程 文件格式」· HTML 代码 · 共 930 行 · 第 1/4 页
HTML
930 行
public static <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/InputStream.html" title="class or interface in java.io">InputStream</A> <B>decode</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/InputStream.html" title="class or interface in java.io">InputStream</A> is, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> encoding) throws <A HREF="../../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></PRE><DL><DD>Decode the given input stream. The Input stream returned is the decoded input stream. All the encodings defined in RFC 2045 are supported here. They include "base64", "quoted-printable", "7bit", "8bit", and "binary". In addition, "uuencode" is also supported.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>is</CODE> - input stream<DD><CODE>encoding</CODE> - the encoding of the stream.<DT><B>Returns:</B><DD>decoded input stream.<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE></DL></DD></DL><HR><A NAME="encode(java.io.OutputStream, java.lang.String)"><!-- --></A><H3>encode</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/OutputStream.html" title="class or interface in java.io">OutputStream</A> <B>encode</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/OutputStream.html" title="class or interface in java.io">OutputStream</A> os, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> encoding) throws <A HREF="../../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></PRE><DL><DD>Wrap an encoder around the given output stream. All the encodings defined in RFC 2045 are supported here. They include "base64", "quoted-printable", "7bit", "8bit" and "binary". In addition, "uuencode" is also supported.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>os</CODE> - output stream<DD><CODE>encoding</CODE> - the encoding of the stream.<DT><B>Returns:</B><DD>output stream that applies the specified encoding.<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE></DL></DD></DL><HR><A NAME="encode(java.io.OutputStream, java.lang.String, java.lang.String)"><!-- --></A><H3>encode</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/OutputStream.html" title="class or interface in java.io">OutputStream</A> <B>encode</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/OutputStream.html" title="class or interface in java.io">OutputStream</A> os, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> encoding, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> filename) throws <A HREF="../../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></PRE><DL><DD>Wrap an encoder around the given output stream. All the encodings defined in RFC 2045 are supported here. They include "base64", "quoted-printable", "7bit", "8bit" and "binary". In addition, "uuencode" is also supported. The <code>filename</code> parameter is used with the "uuencode" encoding and is included in the encoded output.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>os</CODE> - output stream<DD><CODE>encoding</CODE> - the encoding of the stream.<DD><CODE>filename</CODE> - name for the file being encoded (only used with uuencode)<DT><B>Returns:</B><DD>output stream that applies the specified encoding.<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE><DT><B>Since:</B></DT> <DD>JavaMail 1.2</DD></DL></DD></DL><HR><A NAME="encodeText(java.lang.String)"><!-- --></A><H3>encodeText</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>encodeText</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> text) throws <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></PRE><DL><DD>Encode a RFC 822 "text" token into mail-safe form as per RFC 2047. <p> The given Unicode string is examined for non US-ASCII characters. If the string contains only US-ASCII characters, it is returned as-is. If the string contains non US-ASCII characters, it is first character-encoded using the platform's default charset, then transfer-encoded using either the B or Q encoding. The resulting bytes are then returned as a Unicode string containing only ASCII characters. <p> Note that this method should be used to encode only "unstructured" RFC 822 headers. <p> Example of usage: <p><blockquote><pre> MimePart part = ... String rawvalue = "FooBar Mailer, Japanese version 1.1" try { // If we know for sure that rawvalue contains only US-ASCII // characters, we can skip the encoding part part.setHeader("X-mailer", MimeUtility.encodeText(rawvalue)); } catch (UnsupportedEncodingException e) { // encoding failure } catch (MessagingException me) { // setHeader() failure } </pre></blockquote><p><P><DD><DL><DT><B>Parameters:</B><DD><CODE>text</CODE> - Unicode string<DT><B>Returns:</B><DD>Unicode string containing only US-ASCII characters<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></CODE> - if the encoding fails</DL></DD></DL><HR><A NAME="encodeText(java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>encodeText</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>encodeText</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> text, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> charset, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> encoding) throws <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></PRE><DL><DD>Encode a RFC 822 "text" token into mail-safe form as per RFC 2047. <p> The given Unicode string is examined for non US-ASCII characters. If the string contains only US-ASCII characters, it is returned as-is. If the string contains non US-ASCII characters, it is first character-encoded using the specified charset, then transfer-encoded using either the B or Q encoding. The resulting bytes are then returned as a Unicode string containing only ASCII characters. <p> Note that this method should be used to encode only "unstructured" RFC 822 headers.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>text</CODE> - the header value<DD><CODE>charset</CODE> - the charset. If this parameter is null, the platform's default chatset is used.<DD><CODE>encoding</CODE> - the encoding to be used. Currently supported values are "B" and "Q". If this parameter is null, then the "Q" encoding is used if most of characters to be encoded are in the ASCII charset, otherwise "B" encoding is used.<DT><B>Returns:</B><DD>Unicode string containing only US-ASCII characters<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></CODE></DL></DD></DL><HR><A NAME="decodeText(java.lang.String)"><!-- --></A><H3>decodeText</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>decodeText</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> etext) throws <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></PRE><DL><DD>Decode "unstructured" headers, that is, headers that are defined as '*text' as per RFC 822. <p> The string is decoded using the algorithm specified in RFC 2047, Section 6.1. If the charset-conversion fails for any sequence, an UnsupportedEncodingException is thrown. If the String is not an RFC 2047 style encoded header, it is returned as-is <p> Example of usage: <p><blockquote><pre> MimePart part = ... String rawvalue = null; String value = null; try { if ((rawvalue = part.getHeader("X-mailer")[0]) != null) value = MimeUtility.decodeText(rawvalue); } catch (UnsupportedEncodingException e) { // Don't care value = rawvalue; } catch (MessagingException me) { } return value; </pre></blockquote><p><P><DD><DL><DT><B>Parameters:</B><DD><CODE>etext</CODE> - the possibly encoded value<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></CODE> - if the charset conversion failed.</DL></DD></DL><HR><A NAME="encodeWord(java.lang.String)"><!-- --></A><H3>encodeWord</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>encodeWord</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> word) throws <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></PRE><DL><DD>Encode a RFC 822 "word" token into mail-safe form as per RFC 2047. <p> The given Unicode string is examined for non US-ASCII characters. If the string contains only US-ASCII characters, it is returned as-is. If the string contains non US-ASCII characters, it is first character-encoded using the platform's default charset, then transfer-encoded using either the B or Q encoding. The resulting bytes are then returned as a Unicode string containing only ASCII characters. <p> This method is meant to be used when creating RFC 822 "phrases". The InternetAddress class, for example, uses this to encode it's 'phrase' component.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>word</CODE> - Unicode string<DT><B>Returns:</B><DD>Array of Unicode strings containing only US-ASCII characters.<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></CODE> - if the encoding fails</DL></DD></DL><HR><A NAME="encodeWord(java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>encodeWord</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>encodeWord</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> word, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> charset, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> encoding) throws <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></PRE><DL><DD>Encode a RFC 822 "word" token into mail-safe form as per
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?