java种中读取xxx.properties文件的内容
java类中读取xxx.properties文件的内容
1.新建xxx.properties文件,内容格式如下(等号两边不要有空格):
key=value
2.java中获取key值
Properties prop = new Properties(); //如果properties文件和某个java文件在同一目录下,可以如下读取配置文件: InputStream inStream =Test.class.getClassLoader().getResourceAsStream("com/sange/factory/dongtai/xxx.properties") prop.load(inStream);//properties文件 String keyValue = prop.getProperty("key");