Serialization

Serializing Objects

  • Converting objects into a stream of bytes usually for saving, upating a database, folders, etc.
  • Java can automate the serializing of objects for you
  • Implement the serializbale interface
  • Classes ObjectOutputStream and ObjectInputStream can be used to easily write and read objects that are Serializable
  • No new code needed when adding new members
public class StudentClass implements Serializable {
  // Now anything sent here is serializable
}

Serializability

  • Not everything can or should be serializable.
    • Security concerns
    • Technical reasons
      • Why would you serialize a thread, no point
      • The object state only makes sense
  • Specifying a class containing members that aren't serializable
    • Objects of your class can't be serialized
      • Unless you specify those members are "transient"
  • Transient members are not included in the serialized result
    • Can still be useful whtn he member can be computed or determined after deserializing the rest of the object

results matching ""

    No results matching ""