![]() (Of course, this may or may not be desirable depending on the requirements of the system - this is just an example.)Īt the time of deserialization, the readObject method is called to perform any operations necessary to restore the state of the object back to the state at which the serialization occurred. This means that less storage would be needed to save the serialized object. The thumbnailImage field is marked as transient, so only the original image is serialized rather than persisting both the original image and the thumbnail image. In this example, the thumbnailImage is a thumbnail image that is generated by invoking the generateThumbnail method. Throws IOException, ClassNotFoundException ![]() Private void readObject(ObjectInputStream inputStream) Here's a GalleryImage class which contains an image and a thumbnail derived from the image: class GalleryImage implements Serializable transient Fields:įor example, you may have fields that are derived from other fields, and should only be done so programmatically, rather than having the state be persisted via serialization. The transient keyword in Java is used to indicate that a field should not be part of the serialization (which means saved, like to a file) process.įrom the Java Language Specification, Java SE 7 Edition, Section 8.3.1.3. This ensures the JAR is built when executing mvn install or performing a deployment/release. And you run it with mvn clean compile assembly:singleĬompile goal should be added before assembly:single or otherwise the code on your own project is not included.Ĭommonly this goal is tied to a build phase to execute automatically.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |