JAVA,补充完整代码。

JAVA,补充完整代码。
如下所示,目前代码从begin至end部分不一定正确,还请帮忙指正补充,谢谢

package try;

import java.io.*;

public class SerializationUtils {

    public static byte[] serialize(Serializable object) throws Exception {
        // 使用ByteArrayOutputStream和ObjectOutputStream,将对象object序列化为字节数组,并返回
        /********* Begin *********/
        ByteArrayOutputSream out = new ByteArrayOutputStream();

        try(ObjectOutputStream outputStream = new ObjectOutputStream(out)){
            outputStream.writeObject(value);
        }

        return out.toByteArray();
        /********* End *********/
    }

    public static Object deserialize(byte[] data) throws Exception {
        // 使用ByteArrayInputStream和ObjectInputStream,将字节数组data反序列化为对象,并返回
        /********* Begin *********/
        try(ByteArrayInputStream bis = new ByteArrayInputStream(data)){
            
        }
        /********* End *********/
    }

}

已补充正确代码,如下所示:

package try;

import java.io.*;

public class SerializationUtils {

    public static byte[] serialize(Serializable object) throws Exception {
        // 使用ByteArrayOutputStream和ObjectOutputStream,将对象object序列化为字节数组,并返回
        /********* Begin *********/
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(object);

        oos.close();
        return bos.toByteArray();
        /********* End *********/
    }

    public static Object deserialize(byte[] data) throws Exception {
        // 使用ByteArrayInputStream和ObjectInputStream,将字节数组data反序列化为对象,并返回
        /********* Begin *********/
        ByteArrayInputStream bis = new ByteArrayInputStream(data);
        ObjectInputStream ois = new ObjectInputStream(bis);
        Object obj = ois.readObject();
        ois.close();
        return(obj);
        /********* End *********/
    }

}
import java.io.*;

public class SerializationUtils {

    public static byte[] serialize(Serializable object) throws Exception {
        // 使用ByteArrayOutputStream和ObjectOutputStream,将对象object序列化为字节数组,并返回
        /********* Begin *********/
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        try(ObjectOutputStream outputStream = new ObjectOutputStream(out)){
            outputStream.writeObject(object);
        }

        return out.toByteArray();
        /********* End *********/
    }

    public static Object deserialize(byte[] data) throws Exception {
        // 使用ByteArrayInputStream和ObjectInputStream,将字节数组data反序列化为对象,并返回
        /********* Begin *********/
        try(ByteArrayInputStream bis = new ByteArrayInputStream(data);
                ObjectInputStream in = new ObjectInputStream(bis)){
            return in.readObject();
        }
        /********* End *********/
    }
}

你的这个代码是正确的呀 你按照自己的需求补充就行了呀