package my.util;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Properties;
import java.util.ResourceBundle;
/**
* 读写类路径下自定义属性配置文件工具类
*
* @author Administrator
*
*/
public class ReadWriteClasspathProperties {
public ReadWriteClasspathProperties() {
}
/**
* 获取系统文件属性值
*
* @return
*/
public static String getCustomPropertyByKey(String _key) {
ResourceBundle resourceBundle = ResourceBundle
.getBundle(Constant.CUSTOM_SYSTEM_FILE);
return resourceBundle.getString(_key);
}
/**
* 写资源文件
*
* @param filename
* @param _key
* @param _value
*/
public static void writePropertiesFile(String filename, String _key,
String _value) {
Properties properties = new Properties();
try {
OutputStream outputStream = new FileOutputStream(filename);
properties.setProperty(_key, _value);
properties.store(outputStream, "author: test@anxinlirong.com");
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
读写类路径下自定义属性配置文件工具类
最新推荐文章于 2024-11-15 14:09:57 发布