没有合适的资源?快使用搜索试试~ 我知道了~
首页java 动态修改Properties,src下或者指定路径
java 动态修改Properties,src下或者指定路径
![](https://csdnimg.cn/release/wenkucmsfe/public/img/star.98a08eaa.png)
Java 修改Properties文件,src下或者指定路径下的文件。 如果需要修改Properties文件,打成Jar包后又不可以修改。 只能把Properties文件提出jar外进行Properties资源文件修改。
资源详情
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/7237345/bg1.jpg)
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
public class WriteFile {
public static void writeData(String key, String value, String fileURL) {
Properties prop = new Properties();
InputStream fis = null;
OutputStream fos = null;
try {
//java.net.URL url = ConfigUtil.class.getResource(fileURL); //src 目录下
File file = new File(fileURL);//随意目录下 可写如(D:/conf/**)路径
if (!file.exists())
file.createNewFile();
fis = new FileInputStream(file);
prop.load(fis);
fis.close();// 一定要在修改值之前关闭 fis
fos = new FileOutputStream(file);
prop.setProperty(key, value);
prop.store(fos, "Update '" + key + "' value");
fos.close();
} catch (IOException e) {
System.err.println("Visit " + fileURL + " for updating " + value
+ " value error");
} finally {
try {
fos.close();
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
String url = System.getProperty("user.dir")+"\conf\dz\files.properties";
System.out.println(url); ConfigUtil.writeData("outputTxt", "microsoft",url);
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://profile-avatar.csdnimg.cn/default.jpg!1)
歇斯底里的含笑
- 粉丝: 1
- 资源: 5
上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![](https://csdnimg.cn/release/wenkucmsfe/public/img/voice.245cc511.png)
会员权益专享
最新资源
- BSC绩效考核指标汇总 (2).docx
- BSC资料.pdf
- BSC绩效考核指标汇总 (3).pdf
- C5000W常见问题解决方案.docx
- BSC概念 (2).pdf
- ESP8266智能家居.docx
- ESP8266智能家居.pdf
- BSC概念 HR猫猫.docx
- C5000W常见问题解决方案.pdf
- BSC模板:关键绩效指标示例(财务、客户、内部运营、学习成长四个方面).docx
- BSC概念.docx
- BSC模板:关键绩效指标示例(财务、客户、内部运营、学习成长四个方面).pdf
- BSC概念.pdf
- 各种智能算法的总结汇总.docx
- BSC概念 HR猫猫.pdf
- bsc概念hr猫猫.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)