1、url提取参数
public static Map<String, String> getParamFromRequest(String queryString, String charset) throws Exception {
Map<String, String> map = new HashMap<String, String>();
String query = queryString;
if (query != null) {
String[] kvs = query.split("&");
if (kvs != null) {
for (int i = 0; i < kvs.length; i++) {
String[] kv = kvs[i].split("=");
if (kv != null && kv.length == 2) {
if (kv[0] != null && kv[1] != null) {
map.put(kv[0], URLDecoder.decode(kv[1], charset));
}
}
}
}
}
return map;
}
2、深度复制
public static Object deepCopy(Object obj) throws IOException, ClassNotFoundException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(obj);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
return ois.readObject();
}