• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BASE64DecoderStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.mail.util.BASE64DecoderStream的典型用法代码示例。如果您正苦于以下问题:Java BASE64DecoderStream类的具体用法?Java BASE64DecoderStream怎么用?Java BASE64DecoderStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BASE64DecoderStream类属于com.sun.mail.util包,在下文中一共展示了BASE64DecoderStream类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: decode

import com.sun.mail.util.BASE64DecoderStream; //导入依赖的package包/类
/**
    * 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>
    *
    * In the current implementation, if the
    * <code>mail.mime.ignoreunknownencoding</code> system property is set to
    * <code>"true"</code>, unknown encoding values are ignored and the
    * original InputStream is returned.
    *
    * @param	is		input stream
    * @param	encoding	the encoding of the stream.
    * @return			decoded input stream.
    * @exception MessagingException	if the encoding is unknown
    */
   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 {
    if (!ignoreUnknownEncoding)
	throw new MessagingException("Unknown encoding: " + encoding);
    return is;
}
   }
 
开发者ID:konradrenner,项目名称:kore-javamail,代码行数:38,代码来源:MimeUtility.java


示例2: receiveEmailPOPAndroid

import com.sun.mail.util.BASE64DecoderStream; //导入依赖的package包/类
public static void receiveEmailPOPAndroid(MailProfile mailprofile, String folder, int offset, int limit) throws Exception{
	Properties props = new Properties();
       props.setProperty("mail.store.protocol", "pop3");
       props.put("mail.pop3.port", mailprofile.getPop3Port());   
        props.setProperty("mail.pop3.socketFactory.class",
				"javax.net.ssl.SSLSocketFactory");
        props.setProperty("mail.pop3.socketFactory.fallback",
				"false");
        props.setProperty("mail.pop3.port", "" + mailprofile.getPop3Port());
        props.setProperty("mail.pop3.socketFactory.port", ""
				+ mailprofile.getPop3Port());
        
           Session session = Session.getInstance(props, null);
           Store store = session.getStore();
           store.connect(mailprofile.getPop3Host(), mailprofile.getEmail(), mailprofile.getPassword());
           Folder inbox = store.getFolder(folder);
           inbox.open(Folder.READ_ONLY); 
           if(limit > inbox.getMessageCount()) limit = inbox.getMessageCount()-1;
           javax.mail.Message[] msg = inbox.getMessages(inbox.getMessageCount()-offset-limit, inbox.getMessageCount()-offset);
           String content = null;
           javax.mail.Message m;
           try{
            for(int i=msg.length-1; i >= 0; i--){
            	m = msg[i];
            	 Object msgContent = m.getContent();                   
            	     if (msgContent instanceof Multipart) {
            	         Multipart multipart = (Multipart) msgContent;
            	         for (int j = 0; j < multipart.getCount(); j++) {
            	         BodyPart bodyPart = multipart.getBodyPart(j);
            	         String disposition = bodyPart.getDisposition();
            	         if (disposition != null && (disposition.equalsIgnoreCase("ATTACHMENT"))) { 
            	              DataHandler handler = bodyPart.getDataHandler();                 
            	          }
            	          else { 
            	        	  if(bodyPart instanceof IMAPBodyPart){
	            	                 content = ((IMAPBodyPart)bodyPart).getContent().toString();  // the changed code 
	            	                 if(((IMAPBodyPart)bodyPart).getContent() instanceof MimeMultipart){
	            	                	 Multipart multi2 = (Multipart) ((IMAPBodyPart)bodyPart).getContent();
	            	                	 for (int k = 0; k < multi2.getCount(); k++) 
	            	                		 content =multi2.getBodyPart(k).getContent().toString();
	            	        		}
	            	        	}    
            	            }
            	        }
            	     }
            	     else                
            	         content= m.getContent().toString();
            	
            		if(m.getContentType().startsWith("com.sun.mail.util.BASE64DecoderStream"))
            			content = ((BASE64DecoderStream) m.getContent()).toString();
	            	mailprofile.addReceivedMessage(
	            			new Email(
	            					MimeUtility.decodeText(m.getFrom()[0].toString()), 
	            					MimeUtility.decodeText(m.getAllRecipients()[0].toString()), 
	            					MimeUtility.decodeText(m.getSubject()), m.getReceivedDate(), 
	            					content, 
	            					new ArrayList<File>()
	            			)
	            	);
            }
           } catch(Exception e){}
           finally{
           	if(inbox != null)
           		inbox.close(true);
           	if(store != null)
           		store.close();
           }
   
}
 
开发者ID:manuelsc,项目名称:Raven-Messenger,代码行数:70,代码来源:MailControlAndroid.java


示例3: decryptPassword

import com.sun.mail.util.BASE64DecoderStream; //导入依赖的package包/类
/**
 * Decrypts the given encrypted String using the given encryption key, and sets the password to the resulting String
 * @param encryptedString the encrypted password
 * @param key_phrase the String key used to encrypt this password
 * @throws Throwable
 */
public void decryptPassword(String encryptedString, String key_phrase) throws Throwable
{
	DESKeySpec keySpec = new DESKeySpec(key_phrase.getBytes("UTF8"));
	SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
	SecretKey key = keyFactory.generateSecret(keySpec);
	byte[] encrypedPwdBytes = BASE64DecoderStream.decode(encryptedString.getBytes());

	Cipher cipher = Cipher.getInstance("DES");
	cipher.init(Cipher.DECRYPT_MODE, key);
	password = new String(cipher.doFinal(encrypedPwdBytes));
}
 
开发者ID:phil-brown,项目名称:droidMail,代码行数:18,代码来源:MailConfiguration.java



注:本文中的com.sun.mail.util.BASE64DecoderStream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NamespaceSupport类代码示例发布时间:2022-05-23
下一篇:
Java Navigator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap