里面是一些键值对。
first.properties
key1=value1
key2=value2
输出资源文件中对应的内容
import java.io.*;
import java.util.Properties;
public class Test {
public static void main(String[] args) {
Properties properties=new Properties();
String projectPath=System.getProperty("user.dir");//得到类所在的文件夹路径
String propertiesPath=projectPath+File.separator+"resourse"+File.separator+"first.properties";
//得到资源文件的路径
try{
FileInputStream fis=new FileInputStream(propertiesPath);
properties.load(fis);
System.out.println(properties.get("key1"));
System.out.println(properties.get("key2"));
}
catch(Exception e){
e.printStackTrace();
}
}
}