scala: Converting non serializable parent java class to serializable scala class

时间:2019-04-08 13:10:56

标签: java scala serialization deserialization

I have a problem where I am receiving a list of object of a java class type which is coming from other Jar and that java class is not serialized and I need those objects to be serialized in scala program. How to do that.

Example -

//(java class from other.jar)

public class Student {
 // this class contains 100 of members and their getters and setters
}

And this is how I am receiving them in scala program-

 Object MainDriver extends App {
   val nonSerializeObjectList: java.util.ArrayList[Student] = getStudentList() // getStudentsList is giving me list of Student type objects
  import scala.collection.JavaConversions._
  for(student <- nonSerializeObjectList) {
      // here I need student object to be serialized so that I can send them over the network. how to achieve this.
   }
 }

0 个答案:

没有答案
相关问题