package com.pb;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class ReadUtil {
static Properties prop=new Properties();
static {
InputStream in =Thread.currentThread().getContextClassLoader().getResourceAsStream(“name.properties”);
try {
prop.load(in);
} catch (IOException e) {
e.printStackTrace();
}
}
public static String getProperties(String key){
return (String)prop.getProperty(key);
}
}
weixin_45762425 发布了37 篇原创文章 · 获赞 0 · 访问量 436 私信 关注import com.pb.common.Executable;
import java.io.InputStream;
import java.util.Properties;
public class ReadProperties {
/* @Override
public void execute() throws Exception{
//InputStream in =Thread.currentThread().getContextClassLoader().getResourceAsStream(“name.properties”);
Properties props=new Properties();
props.load(in);
System.out.println(props.get(“name”));//
System.out.println(ReadUtil);
}*/
public static void main(String[] args) {
System.out.println(ReadUtil.getProperties(“brokerUrl”));
}
}