如何编写代码来通知 XML 文件更改?

发布于 2024-11-08 16:19:35 字数 252 浏览 0 评论 0原文

我正在使用 java 编写一个 XML gui 编辑器,它编辑 xml 文件,并且有一些程序可以读取该 xml 文件并立即根据更改进行操作。为此,我需要调用 :,我还需要发送少量文本数据 "/n" 。准确地说,我需要提醒特定的 ip 地址,它对 xml 文件进行了一些更改,并且应该重新读取它,以便更改生效。现在关于如何去做有什么想法吗?

I am writing a XML gui editor using java, which edits the xml file and there are programs which would read that xml file and act according the changes immediately. For that purpose, I need to invoke an <ip-address>:<portnumber>, I need to send a small amount of textual data "/n" too. To be precise I need to alert a particular ip adress that some changes has been made to the xml file, and that it should re-read it, so that the changes can take affect. Now any ideas as to how to go about it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

你又不是我 2024-11-15 16:19:35

最简单的解决方案是实施一个基于 UDP 或 TCP/IP 的小型解决方案。除非其他系统已经定义了 API 告诉您如何发送通知。

基于 Java 的客户端/服务器在多个位置进行了描述,这里有一个要求教程的问题。对于这个问题,我建议您查看现有的 API 和/或教程,为了获得详细的答案,我们需要更多的输入。


您可以从这个片段开始 - 但绝对不能保证它在您的环境中实际工作:

Socket socket = new Socket("localhost", 12345);  // replace with real ip/port
Writer out = new PrintWriter(socket.getOutputStream(), true);
out.println();                                   // this sends the '\n'
out.close();
socket.close();

您必须添加一些异常处理。

The easiest solution is to implement a small UDP or TCP/IP based solution. Unless the other system already defines an API telling you how to send a notification.

Java based client/server are described on several locations, here's a SO question that asks for a tutorial. For this question, I suggest you look at the existing API and/or the tutorial, for detailed answers we need more input.


You can start with this snippet - but absolutely no guarantee that it actually works in your environment:

Socket socket = new Socket("localhost", 12345);  // replace with real ip/port
Writer out = new PrintWriter(socket.getOutputStream(), true);
out.println();                                   // this sends the '\n'
out.close();
socket.close();

You'll have to add some exception handling.

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