看例子练apache commons之lang篇
2008-01-05 08:52:10 来源:WEB开发网看commons包时的相关练习,可以用这个包提高编码效率。
package org.raistlin.test.apache;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.CharSet;
import org.apache.commons.lang.CharSetUtils;
import org.apache.commons.lang.ClassUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.SerializationUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang.time.StopWatch;
public class LangDemo
{
public void charSetDemo()
{
System.out.PRintln("**CharSetDemo**");
CharSet charSet = CharSet.getInstance("aeiou");
String demoStr = "The quick brown fox jumps over the lazy dog.";
int count = 0;
for (int i = 0, len = demoStr.length(); i < len; i++)
{
if (charSet.contains(demoStr.charAt(i)))
{
count++;
}
}
System.out.println("count: " + count);
}
public void charSetUtilsDemo()
{
System.out.println("**CharSetUtilsDemo**");
System.out.println("计算字符串中包含某字符数.");
System.out.println(CharSetUtils.count(
"The quick brown fox jumps over the lazy dog.", "aeiou"));
- ››apache设置域名绑定 以及绑定不起作用的排查
- ››apache rewrite将指定URL转向指定的几个服务器
- ››apache配置文件httpd.comf部分参数说明
- ››Apache+Mysql+PHP+phpMyAdmin+Mac OS X 10.7 Lion...
- ››apache+tomcat负载均衡_项目实例
- ››apache mysql php 源码编译使用
- ››Apache添加mod_aspdotnet.so支持ASP.NET配置指南
- ››Apache中改变php.ini的路径
- ››Apache2.2与Tomcat6整合及虚拟主机配置
- ››Apache+php+mysql在windows下的安装与配置图解
- ››Apache+Subversion完美结合,CentOS下实现版本控制...
- ››Apache HTTPServer2.2.16 发布
更多精彩
赞助商链接