Java – stores serializable objects in a file, but does not include some data
•
Java
I have an object that allows me to store buffered image in my target file In the same object, I have the bufferedimage variable, which is used to cache the image after the first load from the original data array When I create an object and store it in a file, everything works because bufferedimage is null There was a problem when I was updating the loaded object and initializing variables and I wanted to save the object after the update
Is it possible to store serializable objects in a file, excluding some variables? Or maybe I can reset my bufferedimage variable in some way when stored in a file?
Thanks in advance, Sergei
Solution
You should mark attributes that you do not want to serialize as transient:
private transient BufferedImage image;
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码