package com.letech.common; import java.io.IOException; import java.util.Properties; public class Constants { protected static Properties pro = new Properties(); static { //初始化 try{ init("icms.properties"); }catch(Exception e){ e.printStackTrace(); } } public final static String USERNAME = getProperty("userName",""); protected static void init(String propertyFileName) { try { pro.load(new IConstants().getClass().getResourceAsStream("/wu.properties")); } catch (IOException e) { e.printStackTrace(); } } protected static String getProperty(String key, String defaultValue) { return pro.getProperty(key, defaultValue); } }
以下是properties
userName=wu