调用方法:String url = PropertiesUtil.getProperty("url");
public class PropertiesUtil { public static Properties property; static { property = new Properties(); InputStream in = PropertiesUtil.class.getResourceAsStream("/init.properties"); try { property.load(in); } catch (IOException e) { e.printStackTrace(); } finally { if (in != null) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } } } public static String getProperty(String key) { return property.getProperty(key); } }