public class T {
public static String Properties(String key,String propertiespath){
String str="";
Properties properties = new Properties();
FileInputStream in = null;
try {
in= new FileInputStream(propertiespath);
properties.load(in); //从配置文件中获取键值对
str=properties.getProperty(key);
in.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
public static String Properties(String key,InputStream in){
String str="";
Properties properties = new Properties();
try {
properties.load(in); //从配置文件中获取键值对
str=properties.getProperty(key);
in.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
application.properties文件内容:
path = c://upload//