WEB开发网
开发学院WEB开发Jsp 看例子练apache commons之lang篇 阅读

看例子练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 jav

看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"));


Tags:例子 apache commons

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接