本文整理汇总了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;未经允许,请勿转载。 |
请发表评论