什么是正确的方式来存储应用程序的Java数据在Java? [英] What is the proper way to store app's conf data in Java?

查看:154
本文介绍了什么是正确的方式来存储应用程序的Java数据在Java?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您在哪里存储J2SE应用程序的用户特定机器特定 运行时配置数据?

where do you store user-specific and machine-specific runtime configuration data for J2SE application?

(例如,Windows上的 C:\Users\USERNAME\AppData\Roaming\ 和Unix上的 / home / username

(For example, C:\Users\USERNAME\AppData\Roaming\ on Windows and /home/username on Unix)

如何以平台无关的方式在文件系统中获取这些位置?

How do you get these locations in the filesystem in platform-independent way?

感谢您的意见

推荐答案

这取决于你的J2SE应用程序:

That depends on your kind of J2SE Application:


  • J2SE可执行文件JAR文件(非常简单):使用 user.home系统属性来查找home-dir。然后相应地创建一个subdir(例如PGP,SVN,... do)

  • Java Web Start提供了非常好的包含安全属性的方法。总是用户特定的

  • 最后Eclipse RCP:你有用户和配置的工作区(也从user.home派生)的概念(不完全确定如何访问Vista )用于计算机广泛使用

  • J2SE executable JAR file (very simple): use user.home System property to find home-dir. Then make a subdir accordingly (like e.g. PGP, SVN, ... do)
  • Java Web Start provides very nice included methods to safe properties. Always user-specific
  • Finally Eclipse RCP: There you have the notion of the workspace (also derived from user.home) for users and configuration (not totally sure how to access that tricky in Vista) for computer wide usage

所有这些方法在小心使用时,请使用正确的 separatorChar - 操作系统中立。

All these approaches are, when used with care -- use correct separatorChar -- OS neutral.

这篇关于什么是正确的方式来存储应用程序的Java数据在Java?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆