Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding serialization process  RSS feed

 
surya.raaj prakash
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I have the class that implements serializable interface,in that i declared 100 variables but i want to save only one variable.
can i declare transient to remainig 99 variables to skip from serialization process?
 
Rok Ć telcer
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure.
 
Muhammad Khojaye
Ranch Hand
Posts: 449
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember transient instance variable brought back as null when deserialize and you need to initialize those instance variable with some default (or original) values otherwise you can suffer with NullPointerExceptions.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool. i dont know about your requirement. but when you say "serialization" ,should careful. google for "serialization proxy pattern".it may useful to you
 
surya.raaj prakash
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
Thanks For Your Replies.

But still I'm not getting the solution
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!