java后台读取配置文件中key与value -----demo2

/**
	 * 
	 * @Title: getValue
	 * @Description: TODO
	 * @param key
	 * @return
	import java.util.Properties;
	 * @return: String
	 */
	public static String getValue(String key){
		Properties prop = new Properties();
		InputStream in = new PropertiesUtil().getClass().getResourceAsStream("/children_task.properties");
		try {
			prop.load(in);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		return prop.getProperty(key);
	}
		public static void main(String[] args) {
			System.out.println("channel="+getValue("channel"));
			System.out.println("url="+getValue("url"));
			
		}

  

 

posted @ 2017-06-13 10:34  ATJAVA  阅读(1468)  评论(0编辑  收藏  举报