import java.io.InputStream; import java.util.Properties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class InterPropertiesUtils { public static final String DEFAULT_CONFIG = "/inter.properties" ; private static Properties config; private static final Log logger = LogFactory.getLog(InterPropertiesUtils .class ); static { config = new Properties(); try { InputStream is = InterPropertiesUtils. class.getResourceAsStream( DEFAULT_CONFIG ); if (is != null) { config .load(is); logger .debug("获取接口配置文件" + DEFAULT_CONFIG+ "信息:\n"+ config ); } else { logger .error("未配置接口配置文件" + DEFAULT_CONFIG+ " !webservice接口可能调用不正确" ); } } catch (Exception e){ logger .error("接口配置文件" + DEFAULT_CONFIG+ " 读取异常!webservice接口可能调用不正确" ,e); } } public static String getProperty(String key) { String value = config .getProperty(key); return value == null ? value : value.trim(); } }
java 从Properties文件读取工具
猜你喜欢
转载自huangzhir.iteye.com/blog/1879199
今日推荐
周排行