java读属性文件实例

xiaoxiao2021-02-28  95

package com.eastcom.first.spark.data.redis; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.Properties; public class PropertiesUtils { private static Properties props = new Properties(); static { try { String redisPropertiesFileDir = System.getProperty("user.dir") + File.separator + "config/redis.properties"; InputStream in = new FileInputStream(new File(redisPropertiesFileDir)); props.load(in); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public static String getValue(String key) { return props.getProperty(key); } public static void updateProperties(String key, String value) { props.setProperty(key, value); } }

转载请注明原文地址: https://www.6miu.com/read-74248.html

最新回复(0)