public class ReflectTest {
public static void main(String[] args) throws Exception {
//config.properties 與當前類在不一樣包下;
InputStream is=ReflectTest.class.getResourceAsStream("/com/jhon/copy/config.properties");
//在同一個包下
//InputStream is=ReflectTest.class.getResourceAsStream("config.properties");
Properties p=new Properties();
p.load(is);
is.close();
String name=p.getProperty("配置字段");
System.out.println(name);
}
}spa