public ComConBen colon() { ComConBen copy = null; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(this); //将流序列化成对象 ByteArrayInputStream
ComConBen copy = null;
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(this);
//将流序列化成对象
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
copy = (ComConBen) ois.readObject();
} catch (IOException e) {
XLog.printExceptionInfo(e);
} catch (ClassNotFoundException e) {
XLog.printExceptionInfo(e);
}
return copy;
}
备注:所有对象需实现 Serializable 接口