读取Properties的流方法
作者:互联网
public static Properties loadProps(String filePath){ Properties properties = new Properties(); try { InputStream in =new BufferedInputStream(new FileInputStream(filePath)); properties.load(in); } catch (Exception e) { e.printStackTrace(); } return properties; } /** * 更新properties文件的键值对 * 如果该主键已经存在,更新该主键的值; * 如果该主键不存在,则插入一对键值。 * @param keyname 键名 * @param keyvalue 键值 */ public static void updateProperty(Properties properties,String filePath,String keyname,String keyvalue) { try { FileOutputStream outputFile = new FileOutputStream(filePath); // 从输入流中读取属性列表(键和元素对) properties.setProperty(keyname, keyvalue); properties.store(outputFile, "Update '" + keyname + "' value"); outputFile.flush(); outputFile.close(); } catch (Exception e) { e.printStackTrace(); } } PropertiesUtils.updateProperty(properties,ph,"QUARTZ_ID",properties.getProperty("QUARTZ_ID"));
标签:outputFile,String,filePath,Properties,new,方法,properties,读取 来源: https://www.cnblogs.com/sunjinwei/p/13917845.html