其实一直都在使用常用工具类,只是从没去整理过,今天空了把一些常用的整理一下吧
怎么使用的一看就明白,另外还有注释,最后的使用pom引入的jar包
public class ApacheCommonsTest {
@Test
public void testCopyNewBean() throws Exception {
StuForm form = new StuForm("lee", 18, 1, new Date(), true);
Stu stu = new Stu();
BeanUtils.copyProperties(form, stu);
System.out.println(stu.toString());
}
@Test
public void testbase64Code() throws Exception {
String name1 = "hello, my name is lee~";
System.out.println("Before: " + name1);
String name2 = base64.encodebase64String(name1.getBytes());
System.out.println("After encode: " + name2);
String name3 = new String(base64.decodebase64(name2));
System.out.println("After decode: " + name3);
String url1 = "www.lee.com.cn";
System.out.println("URL Before: " + url1);
String url2 = base64.encodebase64URLSafeString(url1.getBytes());
System.out.println("URL After decode: " + url2);
String url3 = new String(base64.decodebase64(url2));
System.out.println("URL After decode: " + url3);
}
@Test
public void testCollection() throws Exception {
OrderedMap om = new linkedMap();
om.put("one", 1);
om.put("two", "2");
om.put("three", "three");
om.put("fore", 4);
om.put("five", "5");
System.out.println(om.firstKey());
System.out.println(om.nextKey("fore"));
System.out.println(om.previousKey("five"));
System.out.println("==============================");
BidiMap bm = new TreeBidiMap();
bm.put("three", "3");
bm.put("five", "isfive");
System.out.println(bm.getKey("isfive").toString());
System.out.println(bm.get("three"));
// 交换key和value
BidiMap newMap = bm.inverseBidiMap();
System.out.println(newMap.size());
System.out.println("==============================");
Bag
commons-codec
commons-codec
1.10
org.apache.commons
commons-collections4
4.1
commons-configuration
commons-configuration
1.10