码迷,mamicode.com
首页 > 系统相关 > 详细

ubuntu下的代码格式化工具

时间:2017-08-30 15:29:54      阅读:324      评论:0      收藏:0      [点我收藏+]

标签:java   格式化   internet   xxxx   out   tco   prot   put   res   

indent -kr -i4   SimpleMail.java 可以用,但是太简单

astyle 这个工具不错

http://astyle.sourceforge.net/

技术分享

 

 技术分享

astyle --style=java --style=allman   -f  SimpleMail.java

 

发送邮件的java代码!!亲测可以用

import javax.mail.*;
import javax.mail.internet.*;
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;

import java.util.Properties;

public class SimpleMail
{

    private static final String SMTP_HOST_NAME = "smtp.host.com";
    private static final String SMTP_AUTH_USER = "no-replay@xxxx.com";
    private static final String SMTP_AUTH_PWD = "password";

    public static void main(String[]args) throws Exception
    {   
        new SimpleMail().test();
    }   
    public void test() throws Exception
    {   
        Properties props = new Properties();
        props.put("mail.transport.protocol", "smtp");
        props.put("mail.smtp.host", SMTP_HOST_NAME);
        props.put("mail.smtp.auth", "true");

        Authenticator auth = new SMTPAuthenticator();
        Session mailSession = Session.getDefaultInstance(props, auth);

        // uncomment for debugging infos to stdout
        // mailSession.setDebug(true);
        Transport transport = mailSession.getTransport();

        MimeMessage message = new MimeMessage(mailSession);
        message.setContent("This is a test", "text/plain");
        message.setFrom(new InternetAddress("xxx.com"));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress("12354656@qq.com"));

        transport.connect();
        transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
        transport.close();
    }   
    private class SMTPAuthenticator extends javax.mail.Authenticator
    {   
        public PasswordAuthentication getPasswordAuthentication()
        {
            String username = SMTP_AUTH_USER;
            String password = SMTP_AUTH_PWD;
            return new PasswordAuthentication(username, password);
        }
    }
}

  

ubuntu下的代码格式化工具

标签:java   格式化   internet   xxxx   out   tco   prot   put   res   

原文地址:http://www.cnblogs.com/oxspirt/p/7452911.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!