文件传输 - 基于 XML 的通知和数据交换
我正在使用 Android Sockets,目前我正在尝试通过 WiFi 发送文件。我有一个简单的协议,使用很少的通知类。在 Java 客户端和 Java 服务器上一切正常,但我想对 C#(或 C++)服务器/客户端和 Java 客户端/服务器做同样的事情。我需要决定如何序列化我的通知数据。
我正在考虑 XML 格式。它将包含通知 ID、客户端 ID 和一些数据(即文件块)。
如何将文件块(或任何字节数组)保存到 XML 文件(或基于文本的文件)中?
也许我的想法完全错误?
I am playing around with Android Sockets and I currently I am trying to send a file via WiFi. I have a simple protocol that uses few notification classes. Everything works OK on Java client and Java server, but I want to do the same thing with C# (or C++) server/client and Java client/server. I need to decide how to serialize my notification data.
I was thinking about XML format. It would contain a notification ID, client ID and some data (i.ex. chunk of a file).
How can I save a chunk of a file (or any byte array) into a XML file (or text based file)?
Maybe I am thinking completely wrong way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过 Base64 编码器运行数据,然后将该数据粘贴到 CDATA 部分。 Apache 为 Java 提供了一个 Base64 库。我确信找到一个适用于 C#/C++ 的工具不会太难。
Run your data through a Base64 encoder and then stick that data into a CDATA section in your xml file. Apache makes a Base64 library for Java. I'm sure it wouldn't be too hard to find one for C#/C++.