1, TreeMap ordered map
Unordered and orderly conversion
Use the default construction method:
Public extends extends V> m)
2, map and bean Mutual transfer beanutils is located below Org.apache.commons.beanutils.BeanUtils, its method populate function explains as follows: The Complete method:
Beanutils.populate (Object Bean, Map properties),
This method iterates over the key in the Map<key, value>, and if it has this attribute in the bean, assigns the value of the key to the Bean's property.
2.1. Bean converted to map
Person person1=New person (); Person1.setname ("name1"); Person1.setsex ("sex1"); Map<string, string> map = Beanutils.describe (Person1);
2.2. Map into Bean
Public static <T> T Map2bean (map<string, string> Map, class<t> Class1) { null ; Try { = class1.newinstance (); Beanutils.populate (bean, map); Catch (Exception e) { e.printstacktrace (); } return bean ;
3, Beanutils.copyproperties (A, B) copy
3.1, package Org.springframework.beans;
Beanutils.copyproperties (A, b);//a→b is the value in a.
3.2, package org.apache.commons.beanutils; (common)
Beanutils.copyproperties (A, b);//b→a is a value in
3.3, package org.apache.commons.beanutils; (common)
Propertyutils.copyproperties (A, b);//b→a is a value in
Note: Propertyutils provides the type conversion feature, where the conversion is performed within the range of supported data types when a property of the same name of two JavaBean is found to be of different types, and beanutils does not support this feature, but it is faster.
4. URL encoding and decoding
Code: Java.net.URLEncoder.encode (String s)
Decoding: Java.net.URLDecoder.decode (String s);
5, the string is padded
Org.apache.commons.lang.StringUtils
String test = "123456"= Stringutils.leftpad (test, ten, "0"); System.out.println (value);
Output: 0000123456
008-treemap, map and bean cross-transfer, Beanutils.copyproperties (A, b) copy, URL encoding decoding, string completion