Java Messenger:在计算机上保存消息档案

发布于 2024-12-26 20:47:39 字数 231 浏览 3 评论 0原文

我正在做一个 Java Messenger 供人们聊天,我正在寻找一种在用户计算机上记录消息档案的方法。

我心中有两种可能性:

  • 将对话保存在我存储在文档文件夹中的 XML 文件中。

  • 要使用SQlite,但问题是我不知道如何将它集成到我的安装包中,也不知道它是否非常有用。

对您来说最好的解决方案是什么?

谢谢

I am doing a Java Messenger for people to chat and I an looking for a way to record the message archives on the user's computer.

I have 2 possibilities in my mind :

  • To Save the conversations in XML files that I store in my documents folder.

  • To use SQlite, but the problem is that I don't know how it is possible to integrate it to my setup package and I don't know if it is very useful.

What would be the best solution for you ?

Thank you

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

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

发布评论

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

评论(4

财迷小姐 2025-01-02 20:47:39

另一种选择是使用 JavaDb,它随 Java 6 免费提供(以及更高版本)

在做出选择之前,您应该考虑以下问题:

  1. 大概您希望这对用户透明(即不涉及管理员),
  2. 性能是一个问题吗?
  3. 如果存储模式需要迁移会发生什么,
  4. 您是否需要事务性(我怀疑不太可能)

等等。即使是一个简单的文本文件也很可能就足够了。也许您最好的选择是选择一个简单的解决方案(例如文本文件)并实现它,然后看看您能走多远。但是,请提供合适的持久性级别抽象,以便您将来可以以最小的干扰插入不同的解决方案。

Another option is using JavaDb, which comes for free with Java 6 (and later versions)

Before you make a choice, you should think about questions such as:

  1. presumably you want this transparent to the user (i.e. no admin involved)
  2. is performance an issue ?
  3. what happens if the storage schema needs migration
  4. do you need transactionality (unlikely, I suspect)

etc. It's quite possible that even a simple text file would suffice. Perhaps your best bet is to choose a simple solution (e.g. a text file) and implement that, and see how far it takes you. However, provide a suitable persistence level abstraction such that you can slot in a different solution in the future with minimal disruption.

故人爱我别走 2025-01-02 20:47:39

我会选择 XML 文件,因为它们更通用,并且可以在您的 Messenger 之外以或多或少的人类可读格式打开。我使用 Pidgin 进行即时消息传递,它以 XML 格式保存聊天历史记录。另外,要从应用程序中读取历史记录,您可以轻松地以 HTML 格式进行转换,以便更好地显示它。

I would go for the XML files as they are more generic and could be opened outside your messenger with more or less human readable format. I use Pidgin for instant messaging and it saves chat history in XML. Also to read the history from your application you can transform then easily in HTML to display it nicely.

若言繁花未落 2025-01-02 20:47:39

如果您使用 JAXB,则将 Java 对象与 XML 相互转换非常容易。您只需在类上添加一些注释,然后通过 JAXB 编组器/反编组器运行它们。请参阅 http://docs.oracle.com/javaee/5/tutorial/ doc/bnbay.html

If you use JAXB, converting Java objects to/from XML is very easy. You just put a few annotations on your classes, and run them through a JAXB marshaller/unmarshaller. See http://docs.oracle.com/javaee/5/tutorial/doc/bnbay.html

浅浅淡淡 2025-01-02 20:47:39

使用google的protocolbuffer或者10gen的bson。它们更小、更快。

http://code.google.com/apis/protocolbuffers/docs/javatutorial.html

http://bsonspec.org/

一个问题是这些位于二进制演示文稿中,您可能想要使存档透明/可读用户

Use google's protocolbuffer or 10gen's bson. they are much smaller and faster.

http://code.google.com/apis/protocolbuffers/docs/javatutorial.html

http://bsonspec.org/

One issue is these are in the binary presentation and you might want to make the archive transparent/readable to users

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