动态查找java缓存目录

发布于 2024-11-25 05:37:57 字数 325 浏览 5 评论 0原文

有什么方法可以以编程方式找到java缓存目录吗?

通常它位于这样的目录中:

System.getProperty("user.home") + someMiddleDir + "/Sun/Java/Deployment/cache/" +
    versionCode;

在 Windows Vista 上解析为 "c:/Users/userId/AppData/LocalLow/Sun/Java/Deployment/cache/6.0"

但我需要找到它以某种更动态/精确的方式(最小硬编码代码/路径)。

Is there some way how to find the java cache directory programatically?

Normaly it is located in directory like this:

System.getProperty("user.home") + someMiddleDir + "/Sun/Java/Deployment/cache/" +
    versionCode;

which resolves on Windows Vista into "c:/Users/userId/AppData/LocalLow/Sun/Java/Deployment/cache/6.0"

But I would need to find it in some more dynamic/precise way (minimum hardcoded code/path).

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

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

发布评论

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

评论(2

紧拥背影 2024-12-02 05:37:57

使用这个:

com.sun.deploy.config.Config.getCacheDirectory()

一位好朋友告诉我这个令人讨厌的小方法:)

use this:

com.sun.deploy.config.Config.getCacheDirectory()

one good friend told me about this little nasty method :)

誰ツ都不明白 2024-12-02 05:37:57

更通用的解决方案是读取系统属性deployment.user.cachedir。我用 Java 8 和 9 对此进行了测试,两者都适用于我的情况。

System.getProperty("deployment.user.cachedir")

A more general solution is to read the system property deployment.user.cachedir. I tested this with Java 8 and 9, both work in my case.

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