|
@@ -2,6 +2,7 @@ package com.kmall.admin.haikong.utils;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -11,7 +12,25 @@ import java.util.List;
|
|
|
*/
|
|
|
public class DeepCopyUtils {
|
|
|
|
|
|
- public static <T> Collection<T> depCopy(Collection<T> srcList) {
|
|
|
+ public static <T> Collection<T> depCopyHashSet(Collection<T> srcList) {
|
|
|
+ ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
|
|
+ try {
|
|
|
+ ObjectOutputStream out = new ObjectOutputStream(byteOut);
|
|
|
+ out.writeObject(srcList);
|
|
|
+
|
|
|
+ ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
|
|
|
+ ObjectInputStream inStream = new ObjectInputStream(byteIn);
|
|
|
+ HashSet<T> destList = (HashSet<T>) inStream.readObject();
|
|
|
+ return destList;
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (ClassNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static <T> Collection<T> depCopyList(Collection<T> srcList) {
|
|
|
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
|
|
try {
|
|
|
ObjectOutputStream out = new ObjectOutputStream(byteOut);
|