亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mimeutility.java

?? java Email you can use it to send email to others
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:
/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development * and Distribution License("CDDL") (collectively, the "License").  You * may not use this file except in compliance with the License. You can obtain * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific * language governing permissions and limitations under the License. * * When distributing the software, include this License Header Notice in each * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt. * Sun designates this particular file as subject to the "Classpath" exception * as provided by Sun in the GPL Version 2 section of the License file that * accompanied this code.  If applicable, add the following below the License * Header, with the fields enclosed by brackets [] replaced by your own * identifying information: "Portions Copyrighted [year] * [name of copyright owner]" * * Contributor(s): * * If you wish your version of this file to be governed by only the CDDL or * only the GPL Version 2, indicate your decision by adding "[Contributor] * elects to include this software in this distribution under the [CDDL or GPL * Version 2] license."  If you don't indicate a single choice of license, a * recipient has the option to distribute your version of this file under * either the CDDL, the GPL Version 2 or to extend the choice of license to * its licensees as provided above.  However, if you add GPL Version 2 code * and therefore, elected the GPL Version 2 license, then the option applies * only if the new code is made subject to such option by the copyright * holder. *//* * @(#)MimeUtility.java	1.60 07/05/15 */package javax.mail.internet;import javax.mail.MessagingException;import javax.activation.*;import java.util.*;import java.io.*;import com.sun.mail.util.*;/** * This is a utility class that provides various MIME related * functionality. <p> * * There are a set of methods to encode and decode MIME headers as  * per RFC 2047. A brief description on handling such headers is * given below: <p> * * RFC 822 mail headers <strong>must</strong> contain only US-ASCII * characters. Headers that contain non US-ASCII characters must be * encoded so that they contain only US-ASCII characters. Basically, * this process involves using either BASE64 or QP to encode certain * characters. RFC 2047 describes this in detail. <p> * * In Java, Strings contain (16 bit) Unicode characters. ASCII is a * subset of Unicode (and occupies the range 0 - 127). A String * that contains only ASCII characters is already mail-safe. If the * String contains non US-ASCII characters, it must be encoded. An * additional complexity in this step is that since Unicode is not * yet a widely used charset, one might want to first charset-encode * the String into another charset and then do the transfer-encoding. * <p> * Note that to get the actual bytes of a mail-safe String (say, * for sending over SMTP), one must do  * <p><blockquote><pre> * *	byte[] bytes = string.getBytes("iso-8859-1");	 * * </pre></blockquote><p> *  * The <code>setHeader</code> and <code>addHeader</code> methods * on MimeMessage and MimeBodyPart assume that the given header values * are Unicode strings that contain only US-ASCII characters. Hence * the callers of those methods must insure that the values they pass * do not contain non US-ASCII characters. The methods in this class  * help do this. <p> * * The <code>getHeader</code> family of methods on MimeMessage and * MimeBodyPart return the raw header value. These might be encoded * as per RFC 2047, and if so, must be decoded into Unicode Strings. * The methods in this class help to do this. <p> * * Several System properties control strict conformance to the MIME * spec.  Note that these are not session properties but must be set * globally as System properties. <p> * * The <code>mail.mime.decodetext.strict</code> property controls * decoding of MIME encoded words.  The MIME spec requires that encoded * words start at the beginning of a whitespace separated word.  Some * mailers incorrectly include encoded words in the middle of a word. * If the <code>mail.mime.decodetext.strict</code> System property is * set to <code>"false"</code>, an attempt will be made to decode these * illegal encoded words. The default is true. <p> * * The <code>mail.mime.encodeeol.strict</code> property controls the * choice of Content-Transfer-Encoding for MIME parts that are not of * type "text".  Often such parts will contain textual data for which * an encoding that allows normal end of line conventions is appropriate. * In rare cases, such a part will appear to contain entirely textual * data, but will require an encoding that preserves CR and LF characters * without change.  If the <code>mail.mime.encodeeol.strict</code> * System property is set to <code>"true"</code>, such an encoding will * be used when necessary.  The default is false. <p> * * In addition, the <code>mail.mime.charset</code> System property can * be used to specify the default MIME charset to use for encoded words * and text parts that don't otherwise specify a charset.  Normally, the * default MIME charset is derived from the default Java charset, as * specified in the <code>file.encoding</code> System property.  Most * applications will have no need to explicitly set the default MIME * charset.  In cases where the default MIME charset to be used for * mail messages is different than the charset used for files stored on * the system, this property should be set. * * @version 1.60, 07/05/15 * @author  John Mani * @author  Bill Shannon */public class MimeUtility {    // This class cannot be instantiated    private MimeUtility() { }    public static final int ALL = -1;    private static boolean decodeStrict = true;    private static boolean encodeEolStrict = false;    private static boolean foldEncodedWords = false;    private static boolean foldText = true;    static {	try {	    String s = System.getProperty("mail.mime.decodetext.strict");	    // default to true	    decodeStrict = s == null || !s.equalsIgnoreCase("false");	    s = System.getProperty("mail.mime.encodeeol.strict");	    // default to false	    encodeEolStrict = s != null && s.equalsIgnoreCase("true");	    s = System.getProperty("mail.mime.foldencodedwords");	    // default to false	    foldEncodedWords = s != null && s.equalsIgnoreCase("true");	    s = System.getProperty("mail.mime.foldtext");	    // default to true	    foldText = s == null || !s.equalsIgnoreCase("false");	} catch (SecurityException sex) {	    // ignore it	}    }		    /**     * Get the content-transfer-encoding that should be applied     * to the input stream of this datasource, to make it mailsafe. <p>     *     * The algorithm used here is: <br>     * <ul>     * <li>     * If the primary type of this datasource is "text" and if all     * the bytes in its input stream are US-ASCII, then the encoding     * is "7bit". If more than half of the bytes are non-US-ASCII, then     * the encoding is "base64". If less than half of the bytes are     * non-US-ASCII, then the encoding is "quoted-printable".     * <li>     * If the primary type of this datasource is not "text", then if     * all the bytes of its input stream are US-ASCII, the encoding     * is "7bit". If there is even one non-US-ASCII character, the     * encoding is "base64".     * </ul>     *     * @param	ds	DataSource     * @return		the encoding. This is either "7bit",     *			"quoted-printable" or "base64"     */     public static String getEncoding(DataSource ds) {	ContentType cType = null;	InputStream is = null;	String encoding = null;	try {	    cType = new ContentType(ds.getContentType());	    is = ds.getInputStream();	} catch (Exception ex) {	    return "base64"; // what else ?!	}	boolean isText = cType.match("text/*");	// if not text, stop processing when we see non-ASCII	int i = checkAscii(is, ALL, !isText);	switch (i) {	case ALL_ASCII:	    encoding = "7bit"; // all ascii	    break;	case MOSTLY_ASCII:	    encoding = "quoted-printable"; // mostly ascii	    break;	default:	    encoding = "base64"; // mostly binary	    break;	}	// Close the input stream	try {	    is.close();	} catch (IOException ioex) { }	return encoding;    }    /**     * Same as <code>getEncoding(DataSource)</code> except that instead     * of reading the data from an <code>InputStream</code> it uses the     * <code>writeTo</code> method to examine the data.  This is more     * efficient in the common case of a <code>DataHandler</code>     * created with an object and a MIME type (for example, a     * "text/plain" String) because all the I/O is done in this     * thread.  In the case requiring an <code>InputStream</code> the     * <code>DataHandler</code> uses a thread, a pair of pipe streams,     * and the <code>writeTo</code> method to produce the data. <p>     *     * @since	JavaMail 1.2     */    public static String getEncoding(DataHandler dh) {	ContentType cType = null;	String encoding = null;	/*	 * Try to pick the most efficient means of determining the	 * encoding.  If this DataHandler was created using a DataSource,	 * the getEncoding(DataSource) method is typically faster.  If	 * the DataHandler was created with an object, this method is	 * much faster.  To distinguish the two cases, we use a heuristic.	 * A DataHandler created with an object will always have a null name.	 * A DataHandler created with a DataSource will usually have a	 * non-null name.	 *	 * XXX - This is actually quite a disgusting hack, but it makes	 *	 a common case run over twice as fast.	 */	if (dh.getName() != null)	    return getEncoding(dh.getDataSource());	try {	    cType = new ContentType(dh.getContentType());	} catch (Exception ex) {	    return "base64"; // what else ?!	}	if (cType.match("text/*")) {	    // Check all of the available bytes	    AsciiOutputStream aos = new AsciiOutputStream(false, false);	    try {		dh.writeTo(aos);	    } catch (IOException ex) {	    	// ignore it, can't happen	    }	    switch (aos.getAscii()) {	    case ALL_ASCII:		encoding = "7bit"; // all ascii		break;	    case MOSTLY_ASCII:		encoding = "quoted-printable"; // mostly ascii		break;	    default:		encoding = "base64"; // mostly binary		break;	    }	} else { // not "text"	    // Check all of available bytes, break out if we find	    // at least one non-US-ASCII character	    AsciiOutputStream aos =			new AsciiOutputStream(true, encodeEolStrict);	    try {		dh.writeTo(aos);	    } catch (IOException ex) { }	// ignore it	    if (aos.getAscii() == ALL_ASCII) // all ascii		encoding = "7bit";	    else // found atleast one non-ascii character, use b64 		encoding = "base64";	}	return encoding;    }    /**     * 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.     *     * @param	is		input stream     * @param	encoding	the encoding of the stream.     * @return			decoded input stream.     */    public static InputStream decode(InputStream is, String encoding)		throws MessagingException {	if (encoding.equalsIgnoreCase("base64"))	    return new BASE64DecoderStream(is);	else if (encoding.equalsIgnoreCase("quoted-printable"))	    return new QPDecoderStream(is);	else if (encoding.equalsIgnoreCase("uuencode") ||		 encoding.equalsIgnoreCase("x-uuencode") ||		 encoding.equalsIgnoreCase("x-uue"))	    return new UUDecoderStream(is);	else if (encoding.equalsIgnoreCase("binary") ||		 encoding.equalsIgnoreCase("7bit") ||		 encoding.equalsIgnoreCase("8bit"))	    return is;	else	    throw new MessagingException("Unknown encoding: " + encoding);    }    /**     * 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.     *     * @param	os		output stream     * @param	encoding	the encoding of the stream.      * @return			output stream that applies the     *				specified encoding.     */    public static OutputStream encode(OutputStream os, String encoding)		throws MessagingException {        if (encoding == null)	    return os;	else if (encoding.equalsIgnoreCase("base64"))	    return new BASE64EncoderStream(os);	else if (encoding.equalsIgnoreCase("quoted-printable"))	    return new QPEncoderStream(os);	else if (encoding.equalsIgnoreCase("uuencode") ||		 encoding.equalsIgnoreCase("x-uuencode") ||		 encoding.equalsIgnoreCase("x-uue"))	    return new UUEncoderStream(os);	else if (encoding.equalsIgnoreCase("binary") ||		 encoding.equalsIgnoreCase("7bit") ||		 encoding.equalsIgnoreCase("8bit"))	    return os;	else	    throw new MessagingException("Unknown encoding: " +encoding);    }    /**     * 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.     *     * @param   os              output stream     * @param   encoding        the encoding of the stream.     * @param   filename        name for the file being encoded (only used     *                          with uuencode)     * @return                  output stream that applies the     *                          specified encoding.     * @since                   JavaMail 1.2     */    public static OutputStream encode(OutputStream os, String encoding,                                      String filename)                throws MessagingException {        if (encoding == null)            return os;        else if (encoding.equalsIgnoreCase("base64"))            return new BASE64EncoderStream(os);        else if (encoding.equalsIgnoreCase("quoted-printable"))            return new QPEncoderStream(os);        else if (encoding.equalsIgnoreCase("uuencode") ||                 encoding.equalsIgnoreCase("x-uuencode") ||                 encoding.equalsIgnoreCase("x-uue"))            return new UUEncoderStream(os, filename);        else if (encoding.equalsIgnoreCase("binary") ||                 encoding.equalsIgnoreCase("7bit") ||                 encoding.equalsIgnoreCase("8bit"))            return os;        else            throw new MessagingException("Unknown encoding: " +encoding);    }    /**     * 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,

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人激情图片网| 午夜精品一区在线观看| 97精品久久久午夜一区二区三区| ●精品国产综合乱码久久久久| 91蜜桃免费观看视频| 国产精品国产自产拍高清av王其| 国产高清成人在线| 18涩涩午夜精品.www| 91免费版在线看| 一区二区三区不卡视频在线观看| 色成年激情久久综合| 久久精品国产久精国产爱| 成人免费在线视频| 欧美成人综合网站| 欧美日韩在线播| 成人av电影在线网| 蜜臀av一区二区| 图片区日韩欧美亚洲| 国产片一区二区| 国产欧美一二三区| 欧美视频精品在线| 欧美图区在线视频| 欧美亚男人的天堂| 色婷婷精品久久二区二区蜜臂av | 9191精品国产综合久久久久久| 成人性生交大合| 国产毛片精品视频| 亚洲成av人**亚洲成av**| 一区二区三区免费看视频| 亚洲乱码国产乱码精品精小说| 久久综合色播五月| 日韩精品专区在线影院重磅| 欧美日韩国产成人在线91| 7777女厕盗摄久久久| 91成人网在线| 一本大道久久a久久精二百| av亚洲精华国产精华精| 91香蕉国产在线观看软件| 91网址在线看| 在线免费观看日本欧美| 欧美人与禽zozo性伦| 欧美一级黄色片| 中文字幕不卡在线| 中文幕一区二区三区久久蜜桃| 久久久国产午夜精品| 久久精品亚洲麻豆av一区二区| 中文字幕制服丝袜成人av | 一区二区三区四区av| 偷窥国产亚洲免费视频| 奇米四色…亚洲| 国产伦精品一区二区三区视频青涩| 成人午夜av电影| 日韩欧美一级精品久久| 亚洲最快最全在线视频| 成人免费黄色大片| 国产午夜精品福利| 国产成人精品www牛牛影视| 欧美一区二区三区婷婷月色 | 蜜桃视频第一区免费观看| 欧美系列亚洲系列| 亚洲精品中文在线| 9i看片成人免费高清| 亚洲国产精品精华液ab| 成人激情图片网| 中文字幕亚洲区| 91丝袜国产在线播放| 亚洲视频精选在线| 97久久精品人人做人人爽50路| 欧美日韩高清一区二区| 五月婷婷久久丁香| 日韩一卡二卡三卡四卡| 久久精品免费看| 久久久精品tv| 91麻豆国产在线观看| 一区二区在线观看视频| 欧美日韩国产免费| 日韩和欧美一区二区| 日韩欧美专区在线| 国产成人在线看| 亚洲精品中文字幕乱码三区 | 精品国产伦一区二区三区观看方式 | 亚洲精品videosex极品| 欧美片在线播放| 精品一二线国产| 亚洲男同性恋视频| 日韩一区二区三区在线| 高清久久久久久| 亚洲成a人在线观看| 久久久精品影视| 欧美视频一区二区| 国产精品一区二区在线观看不卡 | 欧美经典三级视频一区二区三区| 成人三级伦理片| 天使萌一区二区三区免费观看| 久久久久国色av免费看影院| 成av人片一区二区| 日本特黄久久久高潮| 国产精品每日更新在线播放网址| 91麻豆精品在线观看| 国内精品免费**视频| 五月婷婷欧美视频| 亚洲精品五月天| 亚洲国产精品国自产拍av| 欧美一级二级三级蜜桃| 91国产精品成人| 欧美视频自拍偷拍| 成人性视频免费网站| 九色|91porny| 免费久久99精品国产| 亚洲h在线观看| 亚洲免费观看高清在线观看| 久久久久久久综合狠狠综合| 欧美精品乱码久久久久久按摩| 91在线观看高清| 91小视频在线观看| 色综合婷婷久久| 成人av在线看| 99精品视频在线观看免费| 91亚洲国产成人精品一区二区三| 成人免费看黄yyy456| 成人午夜免费视频| 97久久精品人人做人人爽50路| 成人美女视频在线看| 97精品久久久午夜一区二区三区| 99精品视频一区| 91久久久免费一区二区| 欧美日韩精品一区二区三区蜜桃| 欧美日韩亚洲丝袜制服| 日韩一二三区不卡| 日本一区二区成人| 亚洲综合免费观看高清完整版在线 | 激情综合一区二区三区| 成人精品国产免费网站| 在线观看国产91| 日韩欧美国产一区二区三区| 精品成人在线观看| 综合av第一页| 老司机午夜精品| 99riav一区二区三区| 在线不卡免费av| 国产精品家庭影院| 日韩精品免费视频人成| 国产毛片一区二区| 欧美男同性恋视频网站| 国产精品天美传媒沈樵| 午夜精品影院在线观看| 国产精品91一区二区| 欧美日韩精品综合在线| 国产日韩一级二级三级| 日本va欧美va精品发布| 91国产视频在线观看| 亚洲国产精品99久久久久久久久| 香蕉成人伊视频在线观看| 99久久亚洲一区二区三区青草| 欧美一区二区日韩| 亚洲欧美一区二区久久| 成人免费看的视频| 精品少妇一区二区| 蜜臀av在线播放一区二区三区| 91在线云播放| 国产欧美日韩另类一区| 国产在线精品不卡| 日韩精品一区二区在线观看| 性做久久久久久| 欧美优质美女网站| 亚洲色图视频免费播放| 91在线丨porny丨国产| 国产精品久久午夜夜伦鲁鲁| 成人免费看片app下载| 国产欧美一区二区精品婷婷| 91视频.com| 国产精品嫩草99a| 成人毛片视频在线观看| 国产精品乱人伦| fc2成人免费人成在线观看播放| 久久亚洲欧美国产精品乐播| 国产一区二区精品久久| 欧美激情综合五月色丁香| 成人av在线看| 亚洲国产精品久久不卡毛片 | 美腿丝袜亚洲三区| 久久久精品人体av艺术| av一区二区三区黑人| 一区二区三区四区在线| 欧美日韩色综合| 麻豆国产欧美一区二区三区| 欧美激情一区在线观看| 在线精品国精品国产尤物884a | 国产一区亚洲一区| 国产精品毛片大码女人| 在线观看一区日韩| 九九国产精品视频| 亚洲美女免费在线| 亚洲精品在线观| 欧美伊人久久大香线蕉综合69| 久久99精品国产.久久久久久 | 国产精品视频在线看| 日韩欧美在线观看一区二区三区| 成人午夜电影网站| 蜜桃一区二区三区四区|