xml| binary | Data in XML, all data is displayed as text, but binary data cannot be represented directly in text format, so how does XML handle binary data? Here is a discussion.
For simplicity and versatility, XML is designed to represent data in text format. In XML, all data is stored in text format, and binary data is no exception. In XML, binary data is encoded into a text format and sent to the destination. The destination party receives this text binary data, then with the same decoding program to solve the corresponding binary data, of course, the original format of the data, name and other ancillary information must be sent together as relevant information. General binary data encoding into BASE64 format, its advantage is easy to encode and decode, the disadvantage is more than pure binary 33% of storage space.
The following are the specific program implementations:
Ret=new Sun.misc.BASE64Encoder (). Encode (bytes); The specific coding method
In.close ();
}
catch (FileNotFoundException e) {
E.printstacktrace ();
}
catch (Java.io.IOException ex) {
Ex.printstacktrace ();
}
%>
A RET is the final result, and the encoding can be sent in a standard XML format. Sent to the destination, but also to the corresponding decoding of the data in order to get the original binary file, decoding the code as follows:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.