import java.io.IOException; import java.io.InputStream; import java.util.Properties; /** * Created by fubin on 2017/1/12 0012. * * * 配置文件加载与访问 * * */ public class PropertiesUtils { private static Properties PRO = new Properties(); static { InputStream ins = null; try { ins = PropertiesUtils.class.getResourceAsStream("/payConfig.properties"); PRO.load(ins); } catch (IOException e) { System.out.println("加载连连支付配置文件失败!"); e.printStackTrace(); } finally { try { ins.close(); } catch (IOException e) { e.printStackTrace(); } } } public static String getConfigValue(String key){ String value = PRO.getProperty(key); return value; } public static final String OID_PARTNER = getConfigValue("OID_PARTNER"); public static final String YT_PUB_KEY = getConfigValue("YT_PUB_KEY"); public static final String MD5_KEY = getConfigValue("MD5_KEY"); public static final String PLATFORM_DOMAIN = "new.vpfinance.cn"; public static final String NOTIFY_URL = getConfigValue("NOTIFY_URL"); public static final String RETURN_URL = getConfigValue("RETURN_URL"); public static final String PRI_KEY_VALUE = getConfigValue("PRI_KEY_VALUE"); public static final String SERVER = getConfigValue("SERVER"); public static final String TRADER_MD5_KEY = getConfigValue("TRADER_MD5_KEY"); public static final String CARD_AND_PAY_NOTIFY = getConfigValue("CARD_AND_PAY_NOTIFY"); public static final String CARD_AND_PAY_URL = getConfigValue("CARD_AND_PAY_URL"); public static void main(String[] args){ String value = PropertiesUtils.getConfigValue("TRADER_MD5_KEY"); System.out.println(value); System.out.println(PropertiesUtils.TRADER_MD5_KEY); } }
时间: 2024-10-26 01:53:39