Java sockets - Custom Objects Sending

前端 未结 2 936
陌清茗
陌清茗 2021-01-24 23:49

I have created working sockets, and when I try to send text or numbers, its ok, but when im trying to send my custom class object, i got NullPointerException... Here is some cod

2条回答
  •  既然无缘
    2021-01-25 00:35

    You need to Serialize your Custom class before sending it through socket.The object that you are sending in

    out.writeObject(list);
    

    should be serialized, your class should implement java.io.Serializable interface

提交回复
热议问题