serialization ArrayList Java

前端 未结 3 1126
既然无缘
既然无缘 2020-12-11 04:02

I want to serialize the Arraylist of type ArrayList and the class contains two Arraylist of primitive type

public class Keyword {

         


        
相关标签:
3条回答
  • 2020-12-11 04:26

    If you want to use Serializable, you should have no problems, because ArrayList is Serializable just as String and every primitive type. public class Keyword implements Serializable {} should do. You can read more about this method here. However there are a lot of other options for serialization. So please be more specific.

    0 讨论(0)
  • 2020-12-11 04:29

    Implement and Interface public class Keyword implements Serializable {} and Simply Use the method of "Object output stream" and "Object input stream" to Serialize and De-serialize the object.

    and Arrylist can be Serialize as normal any data type can serialized.

    0 讨论(0)
  • 2020-12-11 04:33

    inherit the serialization interface in the that class which calss object you want to serialize.

    after that use the ObjectOutput for serialize the object and use the writeObject method for serialize the object.

    0 讨论(0)
提交回复
热议问题