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 = "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下的代码格式化工具的更多相关文章
- Ubuntu下Matlab代码中中文注释乱码解决方案
环境:Ubuntu18.04,Matlab R2017b. 把matlab文件从windows拷贝到Ubuntu中,打开发现原先的中文注释全部乱码.真正原因是因为windows中.m文件采用的是gbk ...
- ubuntu下下载并安装H265(hm.x.x代码和X265代码)
H265,现今是High Efficiency Video Coding的别称,详细的概述见维基百科,详细的开发见官方网站. 一.下载并编译官方的测试源码HM.x.x: 1 ubuntu下安装svn: ...
- 我在 Ubuntu 下使用 Sublime 编写 python 代码时遇到并解决的问题
Ubuntu 下 Sublime 无法输入中文 解决方法如下: sudo apt-get update && sudo apt-get upgrade 克隆项目到本地 : git cl ...
- Ubuntu下使用git提交代码至GitHub
一.Ubuntu下安装Git Ubuntu12.04 LTS默认是已经安装Git的,可以使用 git --version 测试是否安装. 如果没有安装,使用命令: sudo apt-get insta ...
- ubuntu下安装 openssl&&编译运行测试代码
检查是否已安装 openssl: sudo apt-get install openssl 如果已安装执行以下操作:sudo apt-get install libssl-devsudo apt-ge ...
- ubuntu下eclipse打开win下的代码中文出现乱码
问题出现的原因:因为windows下默认的编码是GBK,在ubuntu下是UTF-8所以,所以在windows下的注释,在ubuntu下就变成了乱码. 解决的方案: 1) eclipse->w ...
- 在Ubuntu下搭建ASP.NET 5开发环境
在Ubuntu下搭建ASP.NET 5开发环境 0x00 写在前面的废话 年底这段时间实在太忙了,各种事情都凑在这个时候,没时间去学习自己感兴趣的东西,所以博客也好就没写了.最近工作上有个小功能要做成 ...
- Ubuntu下开启php调试模式,显示报错信息
在Ubuntu下php的缺省设置是不显示错误信息的,如果程序出错会显示“无法处理此请求的错误提示”,这在开发环境下非常不方便. 其实我们只要编辑下apache的配置文件就好 1.我的apache 配置 ...
- Torch7在Ubuntu下的安装与配置
Torch7的本系列教程的主要目的是介绍Torch的入门使用.今天首先分享一下Torch7的安装.(在Ubuntu14.04安装torch7) 为什么选择Torch Torch的目标是在建立科学算法的 ...
随机推荐
- mysql 数据去重
update ptop_investrecord set delflag = 1 where cid = 250 and uid = 92569 and delflag = 0 and progr ...
- url参数为数组
//url中state参数为数组 ?baseline_id=12&version_id=34&state[]=complete&state[]=hangup&state ...
- mina2 笔记
http://www.iteye.com/topic/1112123 http://dongxuan.iteye.com/blog/901689 http://scholers.iteye.com/b ...
- python自动化测试学习笔记-4常用模块
常用模块 1.os 2.sys 3.random 4.string 5.time 6.hashlib 一.os模块 os模块主要用来操作文件.目录,与操作系统无关.要使用os模块首先要导入OS模块,用 ...
- nginx深入
1.编译安装配置完成 /opt/nginx11/html/index.html 这是网页的首页文件 2. nginx.conf主配置文件学习 ############################# ...
- Android 使用 Application 简单介绍
Application 配置全局Context 第一步.写一个全局的单例模式的MyApplication继承自Application 覆盖onCreate ,在这个方法里面实例化Application ...
- Flume NG基本架构与Flume NG核心概念
导读 Flume NG是一个分布式.可靠.可用的系统,它能够将不同数据源的海量日志数据进行高效收集.聚合.移动,最后存储到一个中心化数据存储系统中. 由原来的Flume OG到现在的Flume NG, ...
- Angular——流程控制指令
基本介绍 (1)ng-repeat,类似于for循环,对数组进行遍历 (2)ng-switch on,ng-switch-when,类似于switch,case 基本使用 ng-repeat < ...
- JS高级——eval
eval函数可以用来将字符串转换成JavaScript代码并且运行 <script> eval('var a=10'); console.log(a);//10 </script&g ...
- JS——拖拽盒子
注意事项: 1.opacity是全部元素变透明,rgba只是背景色变透明 2.先是注册鼠标按下的事件,此时就需要记录鼠标在盒子中的坐标 3.再在鼠标按下事件中注册鼠标移动事件,此时鼠标的坐标是不断变化 ...