简体   繁体   中英

Why use XMLEncoder to serialize objects in java?

I understand that java objects can be serialized to a file, but under what circumstances would we need to use an XMLEncoder and serialize an object as XML?

I'm starting to get a grip with Java EE and I understand that we can serialize beans using this method, but why exactly do we need to do it like this and for what purpose?

You'd do this if you were going to pass something to an endpoint (eg REST) that accepts XML that may be part of your app. XML isn't currently as popular as something like JSON but there are still many APIs out there that use it, including something you may end up working on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM