properties store问题

问题描述

properties store问题

使用properties.store方法将修改后的properties对象写入后,原文件没有变化,但下次读取时,读到的是修改后的值,代码如下:

public static void setValue(String key, String value) throws FileNotFoundException, IOException {
        properties.remove(key);
        properties.put(key, value);
        Resource res = new ClassPathResource(
                "/cache/config/property/commonconfig.properties");
        FileOutputStream fileOutputStream = new FileOutputStream(res.getFile());
        properties.store(fileOutputStream, null);
        fileOutputStream.flush();
        fileOutputStream.close();
    }

重启过电脑了,文件还是没变化,值还是修改后的值

时间: 2024-09-09 08:04:56

properties store问题的相关文章

Windows 8 Store Apps学习(39) 契约: Share Contract

介绍 重新想象 Windows 8 Store Apps 之 契约 Share Contract - 右侧边栏称之为 Charm,其 中的"共享"称之为 Share Contract 示例 1.演示如何开发共享源 Contracts/ShareContract/ShareSource.xaml <Page x:Class="XamlDemo.Contracts.ShareContract.ShareSource" xmlns="http://sche

Reading and Writing a Properties File(From Sun)

Reading and Writing a Properties File // Read properties file. Properties properties = new Properties(); try {     properties.load(new FileInputStream(       "infilename")); } catch (IOException e) { }      // Write properties file. try {     pr

Windows 8 Store Apps学习(30) 信息

信息: 获取包信息, 系统信息, 硬件信息, PnP信息, 常用设备信息 介绍 重新想象 Windows 8 Store Apps 之 信息 获取包信息 获取系统信息 获取硬件信息 获取即插即用(PnP: Plug and Play)的设备的信息 获取常用设备信息 示例 1.演示如何获取 app 的 package 信息 Information/PackageInfo.xaml.cs /* * 演示如何获取 app 的 package 信息 */ using System; using Wind

Java中Properties的使用详解

这篇文章主要介绍了Java中Properties的使用详解的相关资料,需要的朋友可以参考下. Java中有个比较重要的类Properties(Java.util.Properties),主要用于读取Java的配置文件,各种语言都有自己所支 持的配置文件,配置文件中很多变量是经常改变的,这样做也是为了方便用户,让用户能够脱离程序本身去修改相关的变量设置.今天,我们就开始Properties的使用. Java中Properties的使用 Properties的文档说明: The Properties

Java中Properties的使用详解_java

Java中有个比较重要的类Properties(Java.util.Properties),主要用于读取Java的配置文件,各种语言都有自己所支 持的配置文件,配置文件中很多变量是经常改变的,这样做也是为了方便用户,让用户能够脱离程序本身去修改相关的变量设置.今天,我们就开始Properties的使用. Java中Properties的使用 Properties的文档说明: The Properties class represents a persistent set of propertie

JAVA之旅(二十九)——文件递归,File结束练习,Properties,Properties存取配置文件,load,Properties的小练习

JAVA之旅(二十九)--文件递归,File结束练习,Properties,Properties存取配置文件,load,Properties的小练习 我们继续学习File 一.文件递归 我们可以来实现一个文件管理器,简单的,但是在此之前,我们先来做点小案例 package com.lgl.hellojava; import java.io.File; public class HelloJJAVA { public static void main(String[] args) { File d

【转】在android程序中使用配置文件properties

在android程序中使用配置文件来管理一些程序的配置信息其实非常简单 在这里我们主要就是用到Properties这个类直接给函数给大家 这个都挺好理解的 读写函数分别如下: //读取配置文件  public Properties loadConfig(Context context, String file) { Properties properties = new Properties(); try { FileInputStream s = new FileInputStream(fil

Eclipse插件开发之定制向导

以前我有一个微型的便携式电子地址薄.我一直认为它很不错,直到有一天它停止运行了.销售该产品的人员无法找回我的联系地址名册,却提议更换一台.这时候我才知道数据的重要性.这个闪亮的小发明与存储在它里面的数据相比根本就不值一提. 在这个序列文章的第一部分中,我介绍了Eclipse插件的开发环境,并开发了一个简单的插件.在第二部分,我添加了工具条按钮.菜单项和对话框.它实际上没有实现任何具体功能.它简单地用某种字体显示了示例文本内容.现在我们要让它能够管理实际的数据.我们将修改这个插件,让它实现我们所需

一个连接池的例子(来自JIVE)(6)

//文件:PropertyManager.java //这个类其实没什么用了,可以去掉,但需要去掉前面几个类中对这个类的引用.package com.qingtuo.db.pool; import java.util.*;import java.io.*; /** * Manages properties for the entire Jive system. Properties are merely * pieces of information that need to be saved