`
yuky1327
  • 浏览: 123256 次
  • 性别: Icon_minigender_2
  • 来自: 广州
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
邮件发送 java 发送邮件
/**
*用apache commons-email 发送邮件
*依赖jar:commons-email.jar,activation.jar,mail.jar
*/
public static void sendMutiMessage() {

		MultiPartEmail email = new MultiPartEmail();
		String[] multiPaths = new String[] { "D:/1.jpg", "D:/2.txt" };

		List<EmailAttachment> list = new ArrayList<EmailAttachment>();
		for (int j = 0; j < multiPaths.length; j++) {
			EmailAttachment attachment = new EmailAttachment();
			//判断当前这个文件路径是否在本地  如果是:setPath  否则  setURL; 
			if (multiPaths[j].indexOf("http") == -1) {
				attachment.setPath(multiPaths[j]);
			} else {
				try {
					attachment.setURL(new URL(multiPaths[j]));
				} catch (MalformedURLException e) {
					e.printStackTrace();
				}
			}
			attachment.setDisposition(EmailAttachment.ATTACHMENT);
			attachment.setDescription("Picture of John");
			list.add(attachment);
		}

		try {
			// 这里是发送服务器的名字:
			email.setHostName("smtp.126.com");
			// 编码集的设置
			email.setCharset("utf-8");
			// 收件人的邮箱				
			email.addTo("slimes@126.com");
			// 发送人的邮箱
			email.setFrom("yuhan0@126.com");
			// 如果需要认证信息的话,设置认证:用户名-密码。分别为发件人在邮件服务器上的注册名称和密码
			email.setAuthentication("yuhan0", "******");
			email.setSubject("这是一封测试邮件");
			// 要发送的信息
			email.setMsg("<b><a href=\"http://www.baidu.com\">邮件测试内容</a></b>");

			for (int a = 0; a < list.size(); a++) //添加多个附件   
			{
				email.attach(list.get(a));
			}
			// 发送
			email.send();
		} catch (EmailException e) {
			e.printStackTrace();
		}
	}

js获取屏幕值 html
var s = "";   
  s += " 网页可见区域宽:"+   document.body.clientWidth;
  s += " 网页可见区域高:"+   document.body.clientHeight;   
  s += " 网页可见区域宽:"+   document.body.offsetWidth     +"   (包括边线和滚动条的宽)";   
  s += " 网页可见区域高:"+   document.body.offsetHeight   +"   (包括边线的宽)";   
  s += " 网页正文全文宽:"+   document.body.scrollWidth;   
  s += " 网页正文全文高:"+   document.body.scrollHeight;   
  s += " 网页被卷去的高:"+   document.body.scrollTop;   
  s += " 网页被卷去的左:"+   document.body.scrollLeft;   
  s += " 网页正文部分上:"+   window.screenTop;   
  s += " 网页正文部分左:"+   window.screenLeft;   
  s += " 屏幕分辨率的高:"+   window.screen.height;   
  s += " 屏幕分辨率的宽:"+   window.screen.width;   
  s += " 屏幕可用工作区高度:"+   window.screen.availHeight;   
  s += " 屏幕可用工作区宽度:"+   window.screen.availWidth;   
  s += " 你的屏幕设置是   "+   window.screen.colorDepth   +"   位彩色";   
  s += " 你的屏幕设置   "+   window.screen.deviceXDPI   +"   像素/英寸";
  alert(s);
html_div_img_自动铺满 html, div, img css 图片自动缩放问题
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>galaxyyang</title>
<style type="text/css">
<!--
#Layer1 {
 position:absolute;
 left:0px;
 top:0px;
 width:599px;
 height:397px;
 z-index:1;
}
body {
 margin-left: 0px;
 margin-top: 0px;
 margin-right: 0px;
 margin-bottom: 0px;
}
-->
</style>
</head>

<script>
 function yy()
 {
   var tt=document.getElementById("cc");
   tt.width=100;  
   tt.height=60;
   }
</script>
<style>
.aaa {
 height: 200px;
 width: 200px;
}
</style>
<body onload="yy()">


<div id="Layer1">
<img src="http://ecshop.appcan.cn/images/pic_index.jpg" width="599" height="397" />

</div>
<div class="aaa"><img src="http://ecshop.appcan.cn/images/pic_index.jpg" name="cc" id="cc" /></div>
</body>
</html>
十六进制小端转换
#include <stdio.h>
#define GetFirstChar(OneWord)      (unsigned char)((OneWord>>(0))&0x00ff)
#define GetSecondChar(OneWord)  (unsigned char)((OneWord>>(8))&0x00ff)
#define GetThirdChar(OneWord)     (unsigned char)((OneWord>>(16))&0x000000ff)
#define GetFourChar(OneWord)      (unsigned char)((OneWord>>(24))&0x000000ff)
//demo 

int main(void)
{
	unsigned int temp=0x3e8; 
	unsigned char one,two,three,four;
	one=GetFirstChar(temp);//one=0x34
    printf("%.2x\n",one);
	two=GetSecondChar(temp);//one=0x12
	printf("%.2x\n",two);
	three=GetThirdChar(temp);//one=0x12
	printf("%.2x\n",three);
	four=GetFourChar(temp);//one=0x12
	printf("%.2x\n",four);
return 0;
}
For循环做String拼装的语法
public String serialize() {
        StringBuilder sb = new StringBuilder();
        boolean first = true;
        for (String key : options.keySet()) {
            if (first) {
                first = false;
            } else {
                sb.append(';');
            }
            sb.append(key).append('=').append(options.get(key));
        }
        return sb.toString();
    }
Global site tag (gtag.js) - Google Analytics