java中获取后缀为properties的文件内容的一些操作

来源:互联网 发布:网络阅读的利与弊 编辑:程序博客网 时间:2024/05/01 06:54
public class Test{public static void main(String args[]) throws Exception{Properties props=new Properties();//后缀为properties的文件中内容为://Type=String//Entity=springFactory.Car//内容为键值对方式,且值不用引号,键值对之间不用符号间隔props.load(Test.class.getClassLoader().getResourceAsStream("springFactory/text.properties"));String type=props.getProperty("Type");System.out.println(type);String entity=props.getProperty("Entity");Car car=(Car)Class.forName(entity).newInstance();car.run();}}

1 0