如何编写代码来通知 XML 文件更改?
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的解决方案是实施一个基于 UDP 或 TCP/IP 的小型解决方案。除非其他系统已经定义了 API 告诉您如何发送通知。
基于 Java 的客户端/服务器在多个位置进行了描述,这里有一个要求教程的问题。对于这个问题,我建议您查看现有的 API 和/或教程,为了获得详细的答案,我们需要更多的输入。
您可以从这个片段开始 - 但绝对不能保证它在您的环境中实际工作:
您必须添加一些异常处理。
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:
You'll have to add some exception handling.