properties java jar,写入包含在Jar文件中作为资源的Java Properties文件

Is there a way to modify the property values in a Properties file that is stored in a Jar file as a Resource?

This is the scenario that I am trying to handle. I have a properties file stored as a resource in my Jar file. There are some system specific properties, for example, paths. I want to be able to change this for the system that I want the Jar file to run on.

The best solution would be to call a class/method that is internal to the Jar file that will modify the resource file that is contained in the Jar. Another solution would be to run a utility program on the Jar file that will modify the property file and re-Jar everything. This will be a one-time setup process that I run on the Jar file.

解决方案

Edit after re-reading the question: are you in a situation where you want to send out the JAR to potentially many people and have it customized on install? If yes, then prefs is the way to go.

If, instead, you're looking to customize for a relatively small number of deployments, then it's probably better to do the customization at build-time.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值