ubuntu下的代码格式化工具
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu下的代码格式化工具相关的知识,希望对你有一定的参考价值。
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 = "[email protected]"; 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("[email protected]")); 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下的代码格式化工具的主要内容,如果未能解决你的问题,请参考以下文章
markdown 在Intel Nuc上设置Ubuntu Web服务器,步骤和代码片段
在Tomcat的安装目录下conf目录下的server.xml文件中增加一个xml代码片段,该代码片段中每个属性的含义与用途