package lang; import java.util.Iterator; import java.util.Map; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ClassUtils; import org.apache.commons.lang.NumberUtils; import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; class Test ... { /** *//** * @param args */ public static void main(String[] args) ...{ // TODO Auto-generated method stub String [] test=...{"33","ddffd"}; String [] test1=...{"ddffd","33"}; System.out.println(ArrayUtils.isEquals(test, test1)); //1.判断两个数据是否相等 System.out.println(ArrayUtils.toString(test)); //2.{33,ddffd} 将数组内容以{,}形式输出. Map map=ArrayUtils.toMap(new String[][] ...{ ...{"RED", "#FF0000"}, ...{"GREEN", "#00FF00"}, ...{"BLUE", "#0000FF"}}); //3.toMap 一个数组,但每个元素 Each element of the array // must be either a {@link java.util.Map.Entry} or an Array, //方式一 下面是遍历map的方式,取得其keySet.iterator(); Iterator it=map.keySet().iterator(); while(it.hasNext())...{ String key=(String) it.next(); //it.next()只包含key System.out.println(key); System.out.println(map.get(key)); } //方式二,取得其entrySet()集合, Iterator it1=map.entrySet().iterator(); while(it.hasNext())...{ Map.Entry entry = (Map.Entry)it1.next(); //it1.next()中包含key和value System.out.println("key :"+entry.getKey()+ "value :"+entry.getValue()); } //4.取得类名 System.out.println(ClassUtils.getShortClassName(Test.class)); //取得其包名 System.out.println(ClassUtils.getPackageName(Test.class)); //5.NumberUtils System.out.println(NumberUtils.stringToInt("6")); //6.五位的随机字母和数字 System.out.println(RandomStringUtils.randomAlphanumeric(5)); //7.StringEscapeUtils System.out.println(StringEscapeUtils.escapeHtml("<html>")); //输出结果为<html> System.out.println(StringEscapeUtils.escapeJava("String")); //8.StringUtils,判断是否是空格字符 System.out.println(StringUtils.isBlank(" ")); //将数组中的内容以,分隔 System.out.println(StringUtils.join(test,",")); //在右边加下字符,使之总长度为6 System.out.println(StringUtils.rightPad("abc", 6, 'T')); //首字母大写 System.out.println(StringUtils.capitalize("abc")); //Deletes all whitespaces from a String 删除所有空格 System.out.println( StringUtils.deleteWhitespace(" ab c ")); //判断是否包含这个字符 System.out.println( StringUtils.contains("abc", "ba")); //表示左边两个字符 System.out.println( StringUtils.left("abc", 2)); System.out.println(NumberUtils.stringToInt("33")); }}