Java MailÎÞ·¨½âÎö´ø·ÖºÅµÄÊÕ¼þÈËÁбíµÄÎÊÌâ
Java MailÎÞ·¨½âÎö´ø·ÖºÅµÄÊÕ¼þÈËÁбíµÄÎÊÌâ
½ñÌìͬÊÂÅöµ½Ò»¸öÎÊÌ⣬ʹÓÃJAVA MAILÊÕÈ¡Óʼþʱ£¬Èç¹ûÊÕ¼þÈËÊǸöÁÐ±í£¬ÇÒÊÕ¼þÈËÁбíÊÇÒԷֺŽøÐзָîµÄ£¬ÔòJAVA MAIL¾Í»á³öÏÖÒì³££¬²»ÄÜÕý³£½âÎö£¬³é¿Õ¿´ÁËÒ»ÑÛ£¬×Ô¼ºÐ´Á˸ö¼òµ¥demo£¬ºÜ¼òµ¥£¬ÀýÈ磺
@Test
public void testReceiveMail() {
try {
String host = "pop3.163.com";
Properties pops = new Properties();
pops.put("mail.pop3.host", host);
pops.put("mail.pop.auth", "true");
Session session = Session.getDefaultInstance(pops, null);
Store store = session.getStore("pop3");
//Á¬½ÓÓʼþ·þÎñÆ÷
store.connect(host, "chb_go", "3870359346");
//ÊÕÈ¡ÊÕ¼þÏä
Folder inbox = store.getDefaultFolder().getFolder("INBOX");
//Ö»¶Á×ã¹»ÁË
inbox.open(Folder.READ_ONLY);
//µÃµ½ËùÓÐÓʼþÁбí
Message[] msg = inbox.getMessages();
FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.ENVELOPE);
inbox.fetch(msg, profile);
for (int i = 0; i < msg.length; i++) {
System.out.println("===============================================");
System.out.println("Ö÷Ì⣺"+msg[i].getSubject());
InternetAddress[] toAddress = (InternetAddress[]) msg[i].getRecipients(Message.RecipientType.TO);
for(InternetAddress adress:toAddress){
System.out.println(adress.getAddress());
}
}
//¹Ø±Õ´ò¿ªµÄ
Ïà¹ØÎĵµ£º
Java´úÂë
final TC[] ts = new TC[20];
for (int i = 0; i < ts.length; i++) {
......
Today , i take the first lesson of java ,let me sum up the details:
firstly,about jdk and jre.jdk stands for java development kit,while jre represent java Runtime Environment. jdk is the key of Java. And,jvm(java virtual machine) is the key of jre.
then ,about the platform independence of java.Dur ......
java.util°üÖоͰüº¬ÁËһϵÁÐÖØÒªµÄ¼¯ºÏÀ࣬¶ø¶ÔÓÚ¼¯ºÏÀ࣬Ö÷ÒªÐèÒªÕÆÎյľÍÊÇËüµÄÄÚ²¿½á¹¹£¬ÒÔ¼°±éÀú¼¯ºÏµÄµü´úģʽ¡£
½Ó¿Ú£ºCollection
ËùÓм¯ºÏÀàµÄ¸ùÀàÐÍ£¬Ö÷ÒªµÄÒ»¸ö½Ó¿Ú·½·¨£ºboolean add(Ojbect c)Ëä·µ»ØµÄÊÇboolean£¬µ«²»ÊDZíʾÌí¼Ó³É¹¦Óë·ñ£¬ÒòΪCollection¹æ¶¨£ºÒ»¸ö¼¯ºÏ¾Ü¾øÌí¼ÓÕâ¸öÔªËØ£¬ÎÞÂÛʲôÔÒò£¬¶¼± ......
¸Õ²ÅÔÚ×ö¸ö²âÊÔʱ ɾ³ýÎļþÀÏÊÇʧ°Ü...Ò»Ö±ÕÒ²»µ½ÔÒò.. file.delete();
×ÜÊÇ·µ»Øfalse.
ÔÚÍøÉÏÕÒÁ˰ëÌì ¶¼ÕÒ²»µ½´íÔÚÄĶù..
if(file.exists() && file.canWrite())
file.delete();
ÕâÑù¶¼²»ÐС
ºóÀ´Í»È»Í»È»Ïëµ½´íÔÚÄĶùÁË..
¾ÍÊÇÔÚдÍêÎļþºóûÓÐclose
out.write(b);
out.flush();
out.close();
......