自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(2)
  • 资源 (76)
  • 收藏
  • 关注

原创 基于JFinal的开源博客系统JFinal_Blog1.1版本发布了

JFinal_Blog是基于JFinal1.5开源系统搭建的博客系统,以91zcm.com 网站作为模板和演示事例,目前已经加入了开源行列。 一、JFinal_Blog 1.1版本发布新增功能点及bug修复情况:1、将数据库连接池由C3P0升级为Druid实现;2、废弃WEB-INF下的数据库连接配置,改用conf下的config.properties来实现配置;3、将上一个版本留下...

2014-06-03 09:28:11 153

原创 JFinal_Blog添加百度Ping和百度SiteMap服务

JFinal_Blog是基于JFinal1.5开源系统搭建的博客系统,以 http://www.91zcm.com 网站作为模板和演示事例,目前已经加入了OSC开源项目和Github开源网站。 一、版本更新:1、添加了百度文章Ping工具;2、添加了百度文章SiteMap工具;3、去掉了项目中多余的PingYinUtil.java类;二、代码调用方法:/**添加到百度博客Ping中**/...

2014-06-03 09:26:51 79

Java调用uploadify实现文件上传Demo实现

Java调用uploadify实现文件上传Demo实现,文档参见:http://www.mbaike.net/java/1940.html

2013-11-01

JS判断是否是图片类型

//判断是否是图片 function isImg(){ var f=$("#imgFile").val(); if(f==""){ alert("请上传图片");return false; }else { if(!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(f)) { alert("图片类型必须是.gif,jpeg,jpg,png中的一种") return false; } } } 主要代码: 来自:http://www.crazyiter.com/software/document/3128.html(疯狂的IT人)

2013-04-06

Android生命周期详解

大家好,今天给大家详解一下Android中Activity的生命周期,我在前面也曾经讲过这方面的内容,但是像网上大多数文章一样,基本都是翻译Android API,过于笼统,相信大家看了,会有一点点的帮助,但是还不能完全吃透,所以我今天特意在重新总结一下:

2013-04-06

疯狂的IT人整理java邮件发送(源码)

java邮件发送(源码),使用说明很全。在搭建系统的时候很给力!

2013-04-05

HTML5+jQuery Mobile模板两套

HTML5+jQuery Mobile模板两套

2013-03-19

情人节LoverDay网页源码

情人节LoverDay网页源码,演示地址:http://www.0817home.com/lover

2012-02-14

最新2012新年祝福网页2012newyear

最新2012新年祝福网页2012newyear,参见地址:http://www.0817home.com/2012newyear

2012-01-13

最新2012年元旦祝福网页

最新2012年元旦祝福网页

2011-12-19

最新2011年圣诞祝福asp+access祝福网页

最新2011年圣诞祝福asp+access祝福网页

2011-12-15

最新2011圣诞祝福网页christmas!

最新2011圣诞祝福网页christmas! 江哥技术博客演示地址:http://www.0817home.com/christmas/

2011-12-15

最全的淘宝客单页面网站

最全的淘宝客单页面网站 欢迎访问江哥技术博客:http:///www.0817home.com 希望和大家一起讨论淘宝客!

2011-11-03

江哥技术博客asp小服务器下载

江哥技术博客asp小服务器下载 详细请访问江哥技术博客:http://www.0817home.com

2011-11-03

最全的discuz论坛版块小图片

最全的discuz论坛版块小图片,包括: 1、20套 精华图标 等级图标 置顶图标; 2、精美论坛版块图标50X50; 3、苹果中国官方的Home; 还有很多,,,欢迎下载 如有问题可以到江哥技术博客(http://www.0817home.com)提问, 江哥技术博客是一个以IT技术评论和技术文章型个人博客,欢迎大家 访问。

2011-11-03

jquery中图片浏览最好的组件

jquery中图片浏览最好的组件,里面有例子!

2011-10-09

缓存服务器memcached代码及使用文档

缓存服务器memcached代码及使用文档,里面整理了使用的文章及J2EE项目使用demo。有问题可以联系:http://www.0817home.com/

2011-10-09

最新2011端午祝福网页源码

端午节,端午节祝福,2011端午节,在线祝福

2011-05-22

《锋利的jquery》实例源码.rar

《锋利的jquery》实例源码.rar《锋利的jquery》实例源码.rar

2010-04-26

jQuery demo例子下载

jQuery demo 例子下载 jQuery demo 例子下载

2010-04-26

jQuery ajax、post、get、json格式传递数据例子

jQuery ajax、post、get、json格式传递数据例子 jQuery ajax、post、get、json格式传递数据例子

2010-04-22

jmf-2_1_1e-windows-i586.exe

java多媒体开发包 java多媒体开发包 jmf-2_1_1e-windows-i586.exe

2010-04-20

Java开发IDE工具eclipse 中OpenExplorer_1.3.0.v201107191404.jar

Java开发IDE工具eclipse 中OpenExplorer_1.3.0.v201107191404.jar

2021-09-18

iOS移动设备管理协议命令参考(2018翻译版)

iOS移动设备管理协议命令参考(2018翻译版)文档是对 2011 年 Black Hat USA 发布的白皮书的后续。本质上它是更新后的附录 A,其中列出了(以非常简 化的形式)Apple iOS MDM 系统使用的各种命令的描述。

2018-04-03

iOS移动设备管理协议(2018翻译版)

目前对于iOS MDM管理协议的文档少之又少,国内中文版本基本没有,有的都是基于2014年我在我的技术博客上发的关于MDM开发的一些文档,这些文档被很多技术博客转载,于此,我在本月决定翻译一下,仅能找到的《BH_US_11_Schuetz_InsideAppleMDM_WP.pdf》这个PDF文档,在此也贡献给开源社区。

2018-03-31

Android制作9.png图片工具及步骤详解

Android制作9.png图片工具及步骤详解(工具、文档齐全,移动互联百科博客提供)

2014-08-05

基于JFinal的开源博客系统JFinal_Blog2.0版本

JFinal_Blog是基于JFinal1.5开源系统搭建的博客系统,以91zcm.com 网站作为模板和演示demo,目前已经加入了OSC开源项目和Github。 一、V2.0 版本新增功能点及bug修复情况: 1、添加百度Ping服务; 2、添加百度SiteMap服务; 3、解决Lucene全文检索出现"too many open files "的bug问题; 4、解决Linux中tomcat容器乱码问题(URLEncoding="UTF-8"); 二、开源地址: 1、OSC介绍:http://www.oschina.net/p/jfinal_blog 2、GIT版本:http://git.oschina.net/jianggege/jfinal_91zcm 3、Github地址:https://github.com/keaijohnee/91zcm 5、演示站点:http://www.91zcm.com/ 感谢大家对于JFinal_Blog的支持!

2014-06-18

Apache Lucene全文检索和IKAnalyzer分词工具类

说明:依赖jar包:lucene-core-2.3.2.jar、IKAnalyzer3.2.8.jar。 一、LuceneUtil 工具类代码: package com.zcm.lucene; import java.io.File; import java.io.IOException; import java.io.StringReader; import java.util.ArrayList; import java.util.List; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.queryParser.MultiFieldQueryParser; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.Hits; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.wltea.analyzer.IKSegmentation; import org.wltea.analyzer.Lexeme; /** * Apache Lucene全文检索和IKAnalyzer分词工具类 * Company: 91注册码 * time:2014-04-22 * @author www.91zcm.com * @date * @version 1.1 */ public class LuceneUtil { /**索引创建的路径**/ private static String LucenePath = "d://index"; /** * 创建索引 * @throws Exception */ public static int createIndex(List list) throws Exception{ /**这里放索引文件的位置**/ File indexDir = new File(LucenePath); Analyzer luceneAnalyzer = new StandardAnalyzer(); /**注意最后一个boolean类型的参数:表示是否重新创建,true表示新创建(以前存在时回覆盖)**/ IndexWriter indexWriter = new IndexWriter(indexDir, luceneAnalyzer,true); for (int i = 0; i < list.size(); i++) { LuceneVO vo = (LuceneVO)list.get(i); Document doc = new Document(); Field FieldId = new Field("aid", String.valueOf(vo.getAid()),Field.Store.YES, Field.Index.NO); Field FieldTitle = new Field("title", vo.getTitle(), Field.Store.YES,Field.Index.TOKENIZED,Field.TermVector.WITH_POSITIONS_OFFSETS); Field FieldRemark = new Field("remark", vo.getRemark(), Field.Store.YES,Field.Index.TOKENIZED,Field.TermVector.WITH_POSITIONS_OFFSETS); doc.add(FieldId); doc.add(FieldTitle); doc.add(FieldRemark); indexWriter.addDocument(doc); } /**查看IndexWriter里面有多少个索引**/ int num = indexWriter.docCount(); System.out.println("总共------》" + num); indexWriter.optimize(); indexWriter.close(); return num; } /** * IKAnalyzer分词 * @param word * @return * @throws IOException */ public static List tokenWord(String word) throws IOException{ List tokenArr = new ArrayList(); StringReader reader = new StringReader(word); /**当为true时,分词器进行最大词长切分**/ IKSegmentation ik = new IKSegmentation(reader, true); Lexeme lexeme = null; while ((lexeme = ik.next()) != null){ tokenArr.add(lexeme.getLexemeText()); } return tokenArr; } /** * 创建索引(单个) * @param list * @throws Exception */ public static void addIndex(LuceneVO vo) throws Exception { /**这里放索引文件的位置**/ File indexDir = new File(LucenePath); Analyzer luceneAnalyzer = new StandardAnalyzer(); IndexWriter indexWriter = new IndexWriter(indexDir, luceneAnalyzer, false); /**增加document到索引去 **/ Document doc = new Document(); Field FieldId = new Field("aid", String.valueOf(vo.getAid()),Field.Store.YES, Field.Index.NO); Field FieldTitle = new Field("title", vo.getTitle(), Field.Store.YES,Field.Index.TOKENIZED,Field.TermVector.WITH_POSITIONS_OFFSETS); Field FieldRemark = new Field("remark", vo.getRemark(), Field.Store.YES,Field.Index.TOKENIZED,Field.TermVector.WITH_POSITIONS_OFFSETS); doc.add(FieldId); doc.add(FieldTitle); doc.add(FieldRemark); indexWriter.addDocument(doc); /**optimize()方法是对索引进行优化 **/ indexWriter.optimize(); indexWriter.close(); } /** * 创建索引(多个) * @param list * @throws Exception */ public static void addIndexs(List list) throws Exception { /**这里放索引文件的位置**/ File indexDir = new File(LucenePath); Analyzer luceneAnalyzer = new StandardAnalyzer(); IndexWriter indexWriter = new IndexWriter(indexDir, luceneAnalyzer,false); /**增加document到索引去 **/ for (int i=0; i<list.size();i++){ LuceneVO vo = (LuceneVO)list.get(i); Document doc = new Document(); Field FieldId = new Field("aid", String.valueOf(vo.getAid()),Field.Store.YES, Field.Index.NO); Field FieldTitle = new Field("title", vo.getTitle(), Field.Store.YES,Field.Index.TOKENIZED,Field.TermVector.WITH_POSITIONS_OFFSETS); Field FieldRemark = new Field("remark", vo.getRemark(), Field.Store.YES,Field.Index.TOKENIZED,Field.TermVector.WITH_POSITIONS_OFFSETS); doc.add(FieldId); doc.add(FieldTitle); doc.add(FieldRemark); indexWriter.addDocument(doc); } /**optimize()方法是对索引进行优化 **/ indexWriter.optimize(); indexWriter.close(); } /** * 更新索引(单个) * @param list * @throws Exception */ public static void updateIndex(LuceneVO vo) throws Exception { /**这里放索引文件的位置**/ File indexDir = new File(LucenePath); Analyzer luceneAnalyzer = new StandardAnalyzer(); IndexWriter indexWriter = new IndexWriter(indexDir, luceneAnalyzer,false); /**增加document到索引去 **/ Document doc = new Document(); Field FieldId = new Field("aid", String.valueOf(vo.getAid()),Field.Store.YES, Field.Index.NO); Field FieldTitle = new Field("title", vo.getTitle(), Field.Store.YES,Field.Index.TOKENIZED,Field.TermVector.WITH_POSITIONS_OFFSETS); Field FieldRemark = new Field("remark", vo.getRemark(), Field.Store.YES,Field.Index.TOKENIZED,Field.TermVector.WITH_POSITIONS_OFFSETS); doc.add(FieldId); doc.add(FieldTitle); doc.add(FieldRemark); Term term = new Term("aid",String.valueOf(vo.getAid())); indexWriter.updateDocument(term, doc); /**optimize()方法是对索引进行优化 **/ indexWriter.optimize(); indexWriter.close(); } /** * 创建索引(多个) * @param list * @throws Exception */ public static void updateIndexs(List list) throws Exception { /**这里放索引文件的位置**/ File indexDir = new File(LucenePath); Analyzer luceneAnalyzer = new StandardAnalyzer(); IndexWriter indexWriter = new IndexWriter(indexDir, luceneAnalyzer,false); /**增加document到索引去 **/ for (int i=0; i<list.size();i++){ LuceneVO vo = (LuceneVO)list.get(i); Document doc = new Document(); Field FieldId = new Field("aid", String.valueOf(vo.getAid()),Field.Store.YES, Field.Index.NO); Field FieldTitle = new Field("title", vo.getTitle(), Field.Store.YES,Field.Index.TOKENIZED,Field.TermVector.WITH_POSITIONS_OFFSETS); Field FieldRemark = new Field("remark", vo.getRemark(), Field.Store.YES,Field.Index.TOKENIZED,Field.TermVector.WITH_POSITIONS_OFFSETS); doc.add(FieldId); doc.add(FieldTitle); doc.add(FieldRemark); Term term = new Term("aid",String.valueOf(vo.getAid())); indexWriter.updateDocument(term, doc); } /**optimize()方法是对索引进行优化 **/ indexWriter.optimize(); indexWriter.close(); } /** * 创建索引(单个) * @param list * @throws Exception */ public static void deleteIndex(LuceneVO vo) throws Exception { /**这里放索引文件的位置**/ File indexDir = new File(LucenePath); Analyzer luceneAnalyzer = new StandardAnalyzer(); IndexWriter indexWriter = new IndexWriter(indexDir, luceneAnalyzer,false); Term term = new Term("aid",String.valueOf(vo.getAid())); indexWriter.deleteDocuments(term); /**optimize()方法是对索引进行优化 **/ indexWriter.optimize(); indexWriter.close(); } /** * 创建索引(多个) * @param list * @throws Exception */ public static void deleteIndexs(List list) throws Exception { /**这里放索引文件的位置**/ File indexDir = new File(LucenePath); Analyzer luceneAnalyzer = new StandardAnalyzer(); IndexWriter indexWriter = new IndexWriter(indexDir, luceneAnalyzer,false); /**删除索引 **/ for (int i=0; i<list.size();i++){ LuceneVO vo = (LuceneVO)list.get(i); Term term = new Term("aid",String.valueOf(vo.getAid())); indexWriter.deleteDocuments(term); } /**optimize()方法是对索引进行优化 **/ indexWriter.optimize(); indexWriter.close(); } /** * 检索数据 * @param word * @return */ public static List search(String word) { List list = new ArrayList(); Hits hits = null; try { IndexSearcher searcher = new IndexSearcher(LucenePath); String[] queries = {word,word}; String[] fields = {"title", "remark"}; BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD, BooleanClause.Occur.SHOULD}; Query query = MultiFieldQueryParser.parse(queries, fields, flags, new StandardAnalyzer()); if (searcher != null) { /**hits结果**/ hits = searcher.search(query); LuceneVO vo = null; for (int i = 0; i < hits.length(); i++) { Document doc = hits.doc(i); vo = new LuceneVO(); vo.setAid(Integer.parseInt(doc.get("aid"))); vo.setRemark(doc.get("remark")); vo.setTitle(doc.get("title")); list.add(vo); } } } catch (Exception ex) { ex.printStackTrace(); } return list; } } 二、Lucene用到的JavaBean代码: package com.zcm.lucene; /** * Apache Lucene全文检索用到的Bean * Company: 91注册码 * time:2014-04-22 * @author www.91zcm.com * @date * @version 1.1 */ public class LuceneVO { private Integer aid; /**文章ID**/ private String title; /**文章标题**/ private String remark; /**文章摘要**/ public Integer getAid() { return aid; } public void setAid(Integer aid) { this.aid = aid; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } } 备注:源码来源于www.91zcm.com 开源博客中的全文检索代码。(http://www.91zcm.com/)

2014-04-22

基于JFinal的开源博客系统JFinal_Blog1.1版本

JFinal_Blog是基于JFinal1.5开源系统搭建的博客系统,以91zcm.com 网站作为模板和演示事例,目前已经加入了开源行列。 JFinal_Blog 1.1版本发布新增功能点: 1、将数据库连接池由C3P0升级为Druid实现; 2、废弃WEB-INF下的数据库连接配置,改用conf下的config.properties来实现配置; 3、将上一个版本留下的SQL模糊Like搜索功能修改为Lucene实现; 4、添加EhCache支持,对首页、列表、标签等叶面做数据缓存; 5、添加"91专题"栏目,将重点添加一些专题文章来提高搜索引擎的收录数量; 6、修复kindeditor上传图片、文件出现404错误的bug; 7、将MyEclipse中运行的启动类独立成com.zcm.starter.Starter.java方便启动。 介绍地址:http://www.91zcm.com/free/429.html(91注册码)

2014-04-19

基于JFinal的开源博客系统

本程序是基于JFinal 1.5做的一个小站,代码没有使用什么特别的东西,用到了@JFinal作者提到的FakeStaticHandler来伪静态,其他的没什么。小站刚开 始使用Lucene来作为全文检索,后面又改成了SQL like匹配,估计要被广大人民喷了。。 后面有时间一定改成Lucene来实现全文检索和分词。 开源说明: 1、小站模板是仿照百度搜索结果自己用table布局来写的顺便练习一下css; 2、部分页面(例如:首页)可以实现缓存,在utils包下面有CacheManager.java可以使用; 3、感谢@JFinal作者的开源精神,JFinal真的很不错,很简单,功能强大,方便开发者; 4、演示地址:http://www.91zcm.com/

2014-01-10

Java实现AES加密和解密算法

本文就简单介绍如何通过JAVA实现AES加密: /** * 测试AES加密和解密 * @param args */ public static void main(String[] args) { /**数据初始化**/ String content = "http://www.mbaike.net"; String password = "1234567890"; /**加密(1)**/ System.out.println("加密前:" + content); byte[] encryptResult = encrypt(content, password); String encryptResultStr = parseByte2HexStr(encryptResult); System.out.println("加密后:" + encryptResultStr); /**解密(2)**/ byte[] decryptFrom = parseHexStr2Byte(encryptResultStr); byte[] decryptResult = decrypt(decryptFrom,password); System.out.println("解密后:" + new String(decryptResult)); } } 说明如下: 在demo中使用了两个转换方法,及二进制转化成十六进制,和十六进制转化成二进制; 我们在AES加密的时候需要使用一个加密算的公共密钥来实现加密和解密; 加密后的字节数组不能直接转化为字符串,需要我们通过给出的两个方法转化;

2013-11-05

最新uploadify.v2.1.0下载含demo

最新uploadify.v2.1.0下载含demo。 具体使用可以参见:http://www.mbaike.net/java/1940.html

2013-11-01

基于IOS上MDM技术相关资料整理及汇总

一、MDM相关知识: MDM (Mobile Device Management ),即移动设备管理。在21世纪的今天,数据是企业宝贵的资产,安全问题更是重中之重,在移动互联网时代,员工个人的设备接入企业网络并查看、收发企业数据已十分普遍,在管理企业移动设备的同时,MDM还能提供全方位安全体系防护,同时在移动设备、移动APP、移动文档三方面进行管理和防护。 二、基于IOS上MDM技术相关资料整理及汇总: 1、理解apple官网提供的相关MDM的开发帮助文档 原文地址:http://www.mbaike.net/ios/1552.html 阶段目标:理解IOS上MDM的原理和工作流程。 2、申请IOS开发MDM需要的https(SSL)证书和密钥 原文地址:http://www.mbaike.net/ios/1554.html 阶段目标:完成https证书申请及流程,为后面部署服务器环境做准备。 3、部署https(SSL)服务器环境 原文地址:http://www.mbaike.net/ios/1556.html 阶段目标:完成https环境的部署和测试,为后面的MDM的测试座准备; 4、MDM推送证书的生成及java-apns组件的测试代码编写 原文地址:http://www.mbaike.net/ios/1558.html 阶段目标:IOS端完成p12格式的MDM推送证书,java-apns组件测试代码的编写; 5、配置描述文件mobileconfig的生成及注意事项 原文地址:http://www.mbaike.net/ios/1560.html 阶段目标:协助IOS端生成mobileconfig文件的生成; 6、安装mobileconfig配置描述文件及完成Authenticate和Token Update功能 原文地址:http://www.mbaike.net/ios/1562.html 阶段目标:完成配置描述的安装和认证过程; 7、获取PushMagic、Token、Topic、UDID、UnlockToken等数据 原文地址:http://www.mbaike.net/ios/1564.html 阶段目标:完成Authenticate和Token Update过程; 8、通过APNS发送MDM的锁屏命令 原文地址:http://www.mbaike.net/ios/1566.html 阶段目标:完成MDM锁屏功能; 9、通过APNS发送MDM的恢复出厂设置命令 原文地址:http://www.mbaike.net/ios/1569.html 阶段目标:完成MDM恢复出厂设置功能; 10、通过APNS发送MDM的查询设备信息的命令 原文地址:http://www.mbaike.net/ios/1571.html 阶段目标:完成MDM查询设备信息功能; 11、mobileconfig文件的签名和认证(signed、verified) 原文地址:http://www.mbaike.net/ios/1578.html 阶段目标:完成MDM的mobileconfig描述文件的签名和认证功能; 12、关于IOS端MDM全部资料的汇总及整理 原文地址:http://www.mbaike.net/ios/1573.html 13、IOS设备上mobileconfig配置文件的卸载及MDM Server标记 原文地址:http://www.mbaike.net/ios/1698.html 阶段目标:完成MDM的mobileconfig描述文件的卸载并并标记服务器; 14、CentOS上MDM相关软件的使用命令整理 原文地址:http://www.mbaike.net/ios/1706.html 阶段目标:完成CentOS上MDM相关软件的使用命令整理; 三、说明: 目前国内基于IOS的MDM相关资料少之又少,作者本人在工作中有幸接触到了一点皮毛,于是将期间的过程整理成文章与广大开发人员一起分享。如果你的从事MDM开发时遇到了这样的问题,可以邮件联系作者,很感谢你的阅读! 转载自:移动互联百科 本文固定链接:http://www.mbaike.net/special/1542.html

2013-10-06

Centos上服务器部署及文件安装命令

Centos上服务器部署及文件安装命令

2013-09-05

java写的将字符串中的中文转化为拼音等一系列方法

package oa.common.utils; import net.sourceforge.pinyin4j.PinyinHelper; import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; /** * 文件名:PingYinUtil.java 拼音工具类 * 版本信息:V1.0 * 日期:2013-06-18 * Copyright BDVCD Corporation 2013 * 版权所有 http://www.bdvcd.com * */ public class PingYinUtil { /** * 将字符串中的中文转化为拼音,其他字符不变 * * @param inputString * @return */ public static String getPingYin(String inputString) { HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat(); format.setCaseType(HanyuPinyinCaseType.LOWERCASE); format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); format.setVCharType(HanyuPinyinVCharType.WITH_V); char[] input = inputString.trim().toCharArray(); String output = ""; try { for (int i = 0; i < input.length; i++) { if (java.lang.Character.toString(input[i]).matches("[\\u4E00-\\u9FA5]+")) { String[] temp = PinyinHelper.toHanyuPinyinStringArray(input[i], format); output += temp[0]; } else output += java.lang.Character.toString(input[i]); } } catch (BadHanyuPinyinOutputFormatCombination e) { e.printStackTrace(); } return output; } /** * 获取汉字串拼音首字母,英文字符不变 * @param chinese 汉字串 * @return 汉语拼音首字母 */ public static String getFirstSpell(String chinese) { StringBuffer pybf = new StringBuffer(); char[] arr = chinese.toCharArray(); HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat(); defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); for (int i = 0; i < arr.length; i++) { if (arr[i] > 128) { try { String[] temp = PinyinHelper.toHanyuPinyinStringArray(arr[i], defaultFormat); if (temp != null) { pybf.append(temp[0].charAt(0)); } } catch (BadHanyuPinyinOutputFormatCombination e) { e.printStackTrace(); } } else { pybf.append(arr[i]); } } return pybf.toString().replaceAll("\\W", "").trim(); } /** * 获取汉字串拼音,英文字符不变 * @param chinese 汉字串 * @return 汉语拼音 */ public static String getFullSpell(String chinese) { StringBuffer pybf = new StringBuffer(); char[] arr = chinese.toCharArray(); HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat(); defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); for (int i = 0; i < arr.length; i++) { if (arr[i] > 128) { try { pybf.append(PinyinHelper.toHanyuPinyinStringArray(arr[i], defaultFormat)[0]); } catch (BadHanyuPinyinOutputFormatCombination e) { e.printStackTrace(); } } else { pybf.append(arr[i]); } } return pybf.toString(); } public static void main(String[] as){ System.out.println(getPingYin("非诚勿扰")); } }

2013-06-30

CacheManager.java 管理缓存

package com.cnfilm.utils; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; /** * 文件名:CacheManager.java 管理缓存 * 版本信息:V1.0 * 日期:2013-06-18 * Copyright BDVCD Corporation 2013 * 版权所有 http://www.bdvcd.com * */ @SuppressWarnings("all") public class CacheManager { private static HashMap cacheMap = new HashMap(); /** * 单实例构造方法 */ private CacheManager() { super(); } /** * 得到缓存。同步静态方法 * * @param key * @return */ public synchronized static Object getCache(String key) { return cacheMap.get(key); } /** * 判断是否存在一个缓存 * * @param key * @return */ public synchronized static boolean hasCache(String key) { return cacheMap.containsKey(key); } /** * 清除所有缓存 */ public synchronized static void clearAll() { cacheMap.clear(); } /** * 清除指定的缓存 * * @param key */ public synchronized static void clearOnly(String key) { cacheMap.remove(key); } /** * 载入缓存 * * @param key * @param obj */ public synchronized static void putCache(String key, Object obj) { cacheMap.put(key, obj); } }

2013-06-30

RssUtils.java 网站RSS生成

package com.cnfilm.utils; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import com.cnfilm.web.film.Film; import com.sun.syndication.feed.rss.Channel; import com.sun.syndication.feed.rss.Description; import com.sun.syndication.feed.rss.Item; import com.sun.syndication.io.FeedException; import com.sun.syndication.io.WireFeedOutput; /** * 文件名:RssUtils.java 网站RSS生成 * 版本信息:V1.0 * 日期:2013-06-18 * Copyright BDVCD Corporation 2013 * 版权所有 http://www.bdvcd.com */ public class RssUtils { public static String getRssString(List filmList,HashMap map){ Channel channel = new Channel("rss_2.0"); channel.setTitle(map.get("title")); channel.setDescription(map.get("description")); channel.setLink("http://www.bdvcd.com/"); channel.setEncoding("UTF-8"); /**这个list对应rss中的item列表**/ List items = new ArrayList(); /**新建Item对象,对应rss中的**/ Item item = null; for(Film film:filmList){ item = new Item(); item.setAuthor(film.getStr("starring")); item.setLink("http://www.bdvcd.com/"+film.getStr("curl")+"/"+film.getStr("url")+".html"); item.setPubDate(DateUtils.parse(film.getStr("addtime"))); item.setTitle(film.getStr("fname")); Description description = new Description(); description.setValue(film.getStr("content")); item.setDescription(description); items.add(item); } channel.setItems(items); /**用WireFeedOutput对象输出rss文本**/ WireFeedOutput out = new WireFeedOutput(); String rssString = ""; try { rssString = out.outputString(channel); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (FeedException e) { e.printStackTrace(); } return rssString; } }

2013-06-30

SharedPrefsUtil.java App存储数据工具类

package com.bdvcd.app.utils; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; /** * 文件名:SharedPrefsUtil.java App存储数据工具类 * 版本信息:V1.0 * 日期:2013-03-11 * Copyright BDVCD Corporation 2013 * 版权所有 http://www.bdvcd.com */ public class SharedPrefsUtil { /** 数据存储的XML名称 **/ public final static String SETTING = "bdvcd"; /** * 存储数据(Long) * * @param context * @param key * @param value */ public static void putLongValue(Context context, String key, long value) { Editor sp = context.getSharedPreferences(SETTING, Context.MODE_PRIVATE) .edit(); sp.putLong(key, value); sp.commit(); } /** * 存储数据(Int) * * @param context * @param key * @param value */ public static void putIntValue(Context context, String key, int value) { Editor sp = context.getSharedPreferences(SETTING, Context.MODE_PRIVATE) .edit(); sp.putInt(key, value); sp.commit(); } /** * 存储数据(String) * * @param context * @param key * @param value */ public static void putStringValue(Context context, String key, String value) { Editor sp = context.getSharedPreferences(SETTING, Context.MODE_PRIVATE) .edit(); sp.putString(key, value); sp.commit(); } /** * 存储数据(boolean) * * @param context * @param key * @param value */ public static void putBooleanValue(Context context, String key, boolean value) { Editor sp = context.getSharedPreferences(SETTING, Context.MODE_PRIVATE) .edit(); sp.putBoolean(key, value); sp.commit(); } /** * 取出数据(Long) * * @param context * @param key * @param defValue * @return */ public static long getLongValue(Context context, String key, long defValue) { SharedPreferences sp = context.getSharedPreferences(SETTING, Context.MODE_PRIVATE); long value = sp.getLong(key, defValue); return value; } /** * 取出数据(int) * * @param context * @param key * @param defValue * @return */ public static int getIntValue(Context context, String key, int defValue) { SharedPreferences sp = context.getSharedPreferences(SETTING, Context.MODE_PRIVATE); int value = sp.getInt(key, defValue); return value; } /** * 取出数据(boolean) * * @param context * @param key * @param defValue * @return */ public static boolean getBooleanValue(Context context, String key, boolean defValue) { SharedPreferences sp = context.getSharedPreferences(SETTING, Context.MODE_PRIVATE); boolean value = sp.getBoolean(key, defValue); return value; } /** * 取出数据(String) * * @param context * @param key * @param defValue * @return */ public static String getStringValue(Context context, String key, String defValue) { SharedPreferences sp = context.getSharedPreferences(SETTING, Context.MODE_PRIVATE); String value = sp.getString(key, defValue); return value; } /** * 清空所有数据 * * @param context * @param key * @param defValue * @return */ public static void clear(Context context) { Editor sp = context.getSharedPreferences(SETTING, Context.MODE_PRIVATE) .edit(); sp.clear(); sp.commit(); } /** * 清空所有数据 * * @param context * @param key * @param defValue * @return */ public static void remove(Context context, String key) { Editor sp = context.getSharedPreferences(SETTING, Context.MODE_PRIVATE) .edit(); sp.remove(key); sp.commit(); } }

2013-06-30

DateUtils.java 日期处理相关工具类

package com.bdvcd.utils; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; /** * 文件名:DateUtils.java 日期处理相关工具类 * 版本信息:V1.0 * 日期:2013-03-11 * Copyright BDVCD Corporation 2013 * 版权所有 http://www.bdvcd.com */ public class DateUtils { /**定义常量**/ public static final String DATE_JFP_STR="yyyyMM"; public static final String DATE_FULL_STR = "yyyy-MM-dd HH:mm:ss"; public static final String DATE_SMALL_STR = "yyyy-MM-dd"; public static final String DATE_KEY_STR = "yyMMddHHmmss"; /** * 使用预设格式提取字符串日期 * @param strDate 日期字符串 * @return */ public static Date parse(String strDate) { return parse(strDate,DATE_FULL_STR); } /** * 使用用户格式提取字符串日期 * @param strDate 日期字符串 * @param pattern 日期格式 * @return */ public static Date parse(String strDate, String pattern) { SimpleDateFormat df = new SimpleDateFormat(pattern); try { return df.parse(strDate); } catch (ParseException e) { e.printStackTrace(); return null; } } /** * 两个时间比较 * @param date * @return */ public static int compareDateWithNow(Date date1){ Date date2 = new Date(); int rnum =date1.compareTo(date2); return rnum; } /** * 两个时间比较(时间戳比较) * @param date * @return */ public static int compareDateWithNow(long date1){ long date2 = dateToUnixTimestamp(); if(date1>date2){ return 1; }else if(date1<date2){ return -1; }else{ return 0; } } /** * 获取系统当前时间 * @return */ public static String getNowTime() { SimpleDateFormat df = new SimpleDateFormat(DATE_FULL_STR); return df.format(new Date()); } /** * 获取系统当前时间 * @return */ public static String getNowTime(String type) { SimpleDateFormat df = new SimpleDateFormat(type); return df.format(new Date()); } /** * 获取系统当前计费期 * @return */ public static String getJFPTime() { SimpleDateFormat df = new SimpleDateFormat(DATE_JFP_STR); return df.format(new Date()); } /** * 将指定的日期转换成Unix时间戳

2013-06-30

程序员面试技巧

程序员面试技巧

2013-06-30

好看的商务PPT模板

好看的商务PPT模板

2013-06-30

利用Java发送邮件(含附件)的例子

利用Java发送邮件(含附件)的例子 1、邮件发送的配置propertity文件内容如下:(utils.properties文件放在src下面) [email protected]=******2、读取配置文件的类文件(ReadPropertity.java) import java.io.IOException;import java.util.Properties;public class ReadPropertity { static Properties props = new Properties(); static { try { props.load(ReadPropertity.class.getClassLoader().getResourceAsStream( "utils.properties")); } catch (IOException e1) { e1.printStackTrace(); } } public static String getProperty(String key) { return props.getProperty(key); }}3、邮件处理类(EmailHandle.java)import java.util.Iterator;import java.util.LinkedList;import java.util.List;import java.util.Properties;import javax.activation.DataHandler;import javax.activation.FileDataSource;import javax.mail.BodyPart;import javax.mail.Message;import javax.mail.Multipart;import javax.mail.Session;import javax.mail.Transport;import javax.mail.internet.InternetAddress;import javax.mail.internet.MimeBodyPart;import javax.mail.internet.MimeMessage;import javax.mail.internet.MimeMultipart;import javax.mail.internet.MimeUtility;/*** 本程序用java来实现Email的发送, 所用到的协议为:smtp* <p>Company: 疯狂的IT人</p>* time:2013-04-05* @author www.crazyiter.com* @date * @version 1.0 */public class EmailHandle { private MimeMessage mimeMsg; //邮件对象 private Session session; //发送邮件的Session会话 private Properties props;//邮件发送时的一些配置信息的一个属性对象 private String sendUserName; //发件人的用户名 private String sendUserPass; //发件人密码 private Multipart mp;//附件添加的组件 private List files = new LinkedList();//存放附件文件 public EmailHandle(String smtp) { sendUserName = ""; sendUserPass = ""; setSmtpHost(smtp);// 设置邮件服务器 createMimeMessage(); // 创建邮件 } public void setSmtpHost(String hostName) { if (props == null) props = System.getProperties(); props.put("mail.smtp.host", hostName); } public boolean createMimeMessage(){ try { // 用props对象来创建并初始化session对象 session = Session.getDefaultInstance(props, null); } catch (Exception e) { System.err.println("获取邮件会话对象时发生错误!" + e); return false; } try { mimeMsg = new MimeMessage(session); // 用session对象来创建并初始化邮件对象 mp = new MimeMultipart();// 生成附件组件的实例 } catch (Exception e) { return false; } return true; } /** * 设置SMTP的身份认证 */ public void setNeedAuth(boolean need) { if (props == null) props = System.getProperties(); if (need) props.put("mail.smtp.auth", "true"); else props.put("mail.smtp.auth", "false"); } /** * 进行用户身份验证时,设置用户名和密码 */ public void setNamePass(String name, String pass) { sendUserName = name; sendUserPass = pass; } /** * 设置邮件主题 * @param mailSubject * @return */ public boolean setSubject(String mailSubject) { try { mimeMsg.setSubject(mailSubject); } catch (Exception e) { return false; } return true; } /** * 设置邮件内容,并设置其为文本格式或HTML文件格式,编码方式为UTF-8 * @param mailBody * @return */ public boolean setBody(String mailBody) { try { BodyPart bp = new MimeBodyPart(); bp.setContent("<meta http-equiv=Content-Type content=text/html; charset=UTF-8>"+ mailBody, "text/html;charset=UTF-8"); // 在组件上添加邮件文本 mp.addBodyPart(bp); } catch (Exception e) { System.err.println("设置邮件正文时发生错误!" + e); return false; } return true; } /** * 增加发送附件 * @param filename * 邮件附件的地址,只能是本机地址而不能是网络地址,否则抛出异常 * @return */ public boolean addFileAffix(String filename) { try { BodyPart bp = new MimeBodyPart(); FileDataSource fileds = new FileDataSource(filename); bp.setDataHandler(new DataHandler(fileds)); bp.setFileName(MimeUtility.encodeText(fileds.getName(),"utf-8",null)); // 解决附件名称乱码 mp.addBodyPart(bp);// 添加附件 files.add(fileds); } catch (Exception e) { System.err.println("增加邮件附件:" + filename + "发生错误!" + e); return false; } return true; } public boolean delFileAffix(){ try { FileDataSource fileds = null; for(Iterator it = files.iterator() ;it.hasNext();) { fileds = (FileDataSource)it.next(); if(fileds != null && fileds.getFile() != null){ fileds.getFile().delete(); } } }catch (Exception e) { return false; } return true; } /** * 设置发件人地址 * @param from * 发件人地址 * @return */ public boolean setFrom(String from) { try { mimeMsg.setFrom(new InternetAddress(from)); } catch (Exception e) { return false; } return true; } /** * 设置收件人地址 * @param to收件人的地址 * @return */ public boolean setTo(String to) { if (to == null) return false; try { mimeMsg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to)); } catch (Exception e) { return false; } return true; } /** * 发送附件 * @param copyto * @return */ public boolean setCopyTo(String copyto) { if (copyto == null) return false; try { mimeMsg.setRecipients(javax.mail.Message.RecipientType.CC,InternetAddress.parse(copyto)); } catch (Exception e) { return false; } return true; } /** * 发送邮件 * @return */ public boolean sendEmail() throws Exception{ mimeMsg.setContent(mp); mimeMsg.saveChanges(); System.out.println("正在发送邮件...."); Session mailSession = Session.getInstance(props, null); Transport transport = mailSession.getTransport("smtp"); // 连接邮件服务器并进行身份验证 transport.connect((String) props.get("mail.smtp.host"), sendUserName,sendUserPass); // 发送邮件 transport.sendMessage(mimeMsg, mimeMsg.getRecipients(Message.RecipientType.TO)); System.out.println("发送邮件成功!"); transport.close(); return true; }}4、邮件发送的类文件(SendEmail.java)/*** 发送邮件测试* <p>Company: 疯狂的IT人</p>* time:2013-04-05* @author www.crazyiter.com* @date * @version 1.0 */public class SendEmail { public SendEmail() { } /***以后需要两个参数:接收方地址 、 内容***/ public static void send(String subject, String toaddress,String content)throws Exception { String hostName = ReadPropertity.getProperty("emailsmtp"); String fromAddress = ReadPropertity.getProperty("emailaddress"); String fromAPass = ReadPropertity.getProperty("emailpass"); EmailHandle emailHandle = new EmailHandle(hostName); emailHandle.setFrom(fromAddress); emailHandle.setNeedAuth(true); emailHandle.setSubject(subject); emailHandle.setBody(content); emailHandle.setTo(toaddress); emailHandle.setFrom(fromAddress); emailHandle.addFileAffix("D:/myself/help/txt/java环境变量.txt");// 附件文件路径 emailHandle.setNamePass(fromAddress, fromAPass); emailHandle.sendEmail(); } public static void main(String[] args) { try { SendEmail.send("带附件的邮件测试","[email protected]","测试内容<a href='http://www.crazyiter.com'>疯狂的IT人</a>"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }}5、发送邮件需要的jar包:activation.jarmail-plugin.jarmail.jar6、打包下载: 疯狂的IT人整理java邮件发送(源码).rar 下载地址: http://www.crazyiter.com/bbs/forum.php?mod=attachment&aid=MjF8MzQzOTYzZjB8MTM2NTE3NjczMHwxfDExNDA%3D

2013-04-06

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除