public class DeepCloneTool { public DeepCloneTool() { } public static Object deepClone(Object oIn) throws Exception { Object value = null; try { ByteArrayOutputStream buf = new ByteArrayOutputStream(); ObjectOutputStream o = new ObjectOutputStream(buf); o.writeObject(oIn); ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buf.toByteArray())); value = in.readObject(); return value; } catch (IOException var5) { throw new Exception(var5); } } }
复制java类,总是指向同一个对象
最新推荐文章于 2023-02-01 18:28:51 发布