- package com.simple.test;
-
- import java.util.Date;
- import java.util.Iterator;
- import java.util.Map;
-
- import org.apache.commons.lang3.ArrayUtils;
- import org.apache.commons.lang3.ClassUtils;
- import org.apache.commons.lang3.RandomStringUtils;
- import org.apache.commons.lang3.StringEscapeUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.commons.lang3.SystemUtils;
- import org.apache.commons.lang3.math.NumberUtils;
- import org.apache.commons.lang3.time.DateFormatUtils;
- import org.apache.commons.lang3.time.DateUtils;
- import org.junit.Test;
-
- public class TestString {
-
- public static void main(String[] args) {
- String[] test = { "33", "ddffd" };
- String[] test2 = { "33", "ddffd" };
- String[] test1 = { "ddffd", "33" };
-
-
- System.out.println("判断两个数组是否相同: " + ArrayUtils.isEquals(test, test2));
- System.out.println("判断数组中是否包含一个对象: " + ArrayUtils.contains(test, "33"));
-
-
- System.out.println("输出数组中的数据: "+ArrayUtils.toString(test));
-
- System.out.println("讲一个二维数组转换成MAP....");
- Map map = ArrayUtils.toMap(new String[][] { { "RED", "#FF0000" }, { "GREEN", "#00FF00" }, { "BLUE", "#0000FF" } });
-
-
-
- Iterator it = map.keySet().iterator();
- while (it.hasNext()) {
- String key = (String) it.next();
-
- System.out.println("key:" + key + "value:" + map.get(key));
- }
- System.out.println("讲一个二维数组转换成MAP 打印结束....");
-
- Iterator it1 = map.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry entry = (Map.Entry) it1.next();
-
- System.out.println("key :" + entry.getKey() + "value :" + entry.getValue());
- }
-
-
- System.out.println("取得一个类的名称: "+ ClassUtils.getShortClassName(Test.class));
-
- System.out.println("取得一个类的包名: "+ ClassUtils.getPackageName(Test.class));
-
- System.out.println("将一个字符串转换成数字: "+ NumberUtils.toInt("6"));
- System.out.println("将一个字符串转换成数字, 输入一个默认参数: "+ NumberUtils.toInt("7", 10));
-
-
- System.out.println("取得随机字母和数字: "+RandomStringUtils.randomAlphanumeric(15));
-
- System.out.println(StringEscapeUtils.unescapeHtml3("