读取配置文件工具类
package com.test.abc.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class Sysconfig {
	private static Properties sysConfig = new Properties();
	static { // 读取配置文件
		InputStream inputStream = Sysconfig.class
		.getResourceAsStream("/infterfaceAddr.properties");
		try {
			sysConfig.load(inputStream);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				inputStream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	// 根据属性读取配置文件
	public static String getProperty(String key) {
		return sysConfig.getProperty(key);
	}
	// 根据属性写入配置文件
	public static void setProperty(String key, String value) {
		sysConfig.setProperty(key, value);
	}
}
本文来自博客园,作者:bgtong,转载请注明原文链接:https://www.cnblogs.com/bgtong/p/16066974.html
 
                    
                 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号