The powerful weapon in Java-Object serialization-general Linux technology-Linux programming and kernel information. The following is a detailed description. Object serialization converts the state of an object to throttling. You can use these values to generate objects in the same state. This process can also be achieved through the network. You can first create an object on a Windows machine, serialize it, and then send it to a Unix machine through the network, then re-assemble it exactly ". Is it amazing.
You may say that you only know a little bit, but you have never been in touch with it. In fact, this is not necessarily the case. RMI, Socket, JMS, and EJB should have been used. Why can each other transmit Java objects? Of course, they are all contributed by the object serialization mechanism.
The first time I used Java object serialization, I made a XXX project (in fact, I only used this time, so do not throw any vegetables or fruits ^ _*), at that time, it was required to save several very complex trees (jtrees) and corresponding data (which is our frequently used storage function) so that the last operation can be continued during the next running of the program. At that time, XML technology was very popular on the Internet, and its functions were also powerful. The structure of the tree was originally similar to the format of XML data storage. Of course I would like to try it out as a new technology. However, after careful analysis, we found that if XML is used to store data, the result is really hard to imagine: Which node of the tree is expanded to the nth level, and what is the current attribute of the node. I really don't know whether to use A, B, C or 1, 2, or 3. Fortunately, the Java object serialization mechanism was discovered, and the problem was solved. Simply serialize the root node of each tree and save it to the hard disk, next time, the root node after deserialization can easily construct the same tree as the original one.
In fact, the storage of data, especially complex data, is a typical application of Object serialization. Recently, the YYY project encountered the need to access very complex data. By using object serialization, the problem is also difficult to simplify.
Another easy-to-be-ignored feature of Object serialization is object replication (Clone). in Java, the Clone mechanism can be used to copy most objects. But as we all know, Clone has deep Clone and shallow Clone, if your object is very complex, assume that there is a Collection (exaggerated) on the 100 layer. If you want to implement deep Clone, you can't imagine it. If you want to use serialization, no more than 10 lines of code can be solved. There is also the Swing component. If you have two very (or exactly the same) Difficult-to-construct Swing components, what should you do? Maybe you think of Clone, however, the Swing component does not provide the Clone method. Don't worry, use serialization, six lines of code,