文件传输 - 基于 XML 的通知和数据交换

发布于 2024-11-06 00:57:00 字数 270 浏览 8 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

套路撩心 2024-11-13 00:57:00

通过 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++.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文