Java OutputStream相当于getClass()。getClassLoader()。getResourceAsStream() [英] Java OutputStream equivalent to getClass().getClassLoader().getResourceAsStream()

查看:359
本文介绍了Java OutputStream相当于getClass()。getClassLoader()。getResourceAsStream()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图存储对我的应用程序属性所做的更改。 .properties 文件位于 resources 包中,这与包含我的UI和模型的包不同。 / p>

我打开了这个包:

$ p $ this.getClass()。 getClassLoader()。getResourceAsStream(resources / settings.properties)

这允许我坚持改变属性类在相同的.Properties文件?

解决方案

这听起来像你想存储用户优先。考虑使用 Java首选项API


I am attempting to store the change made to my application's properties. The .properties file is located in resources package, which is different from the package that contains my UI and model.

I opened the package using:

this.getClass().getClassLoader().getResourceAsStream("resources/settings.properties")

Is there a functional equivalent of this that permits me to persist changes to the Properties Class in the same .Properties file?

解决方案

It sounds like you want to store user preferences. Consider using the Java Preferences API for that.

这篇关于Java OutputStream相当于getClass()。getClassLoader()。getResourceAsStream()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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