当前位置 : 主页 > 编程语言 > c++ >

Propeties类加载器

来源:互联网 收集:自由互联 发布时间:2021-06-30
PropertiseReader.java package test;import java.io.IOException;import java.io.InputStream;import java.util.Enumeration;import java.util.HashMap;import java.util.Map;import java.util.Properties;//propertiseļpublic class PropertiseReader {pri
PropertiseReader.java
package test;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

//propertiseļ
public class PropertiseReader {
	private static InputStream in = PropertiseReader.class.getResourceAsStream("factory.properties");
	private static Map
 
   KV;
	private static Properties factoryproperty;
	
	private PropertiseReader() {
		try{
			factoryproperty=new Properties();
			KV=new HashMap<>();
        	factoryproperty.load(in);
        	Enumeration
  
    key= (Enumeration
   
    ) factoryproperty.propertyNames(); while(key.hasMoreElements()){ String K=key.nextElement(); String V=factoryproperty.getProperty(K); KV.put(K, V);} }catch(IOException e){} } private static PropertiseReader imp=new PropertiseReader(); public static Map
    
      mapgetElement(){ return KV; } }
    
   
  
 
Testpropertise.java
package test;

import java.util.Map;

public class Testpropertise {

	public static void main(String[] args) {
		Map
 
   pro=PropertiseReader.mapgetElement();
		System.out.println(pro.toString());

	}

}
 
网友评论