文件上传

文件上传保存的文件路径为和部署Tomcat同级的目录

String tomcatPath = System.getProperty("catalina.home");//获取tomcat目录
File curAllInOneProjectFile = new File(tomcatPath);
File rootProjectFileDir = curAllInOneProjectFile.getParentFile();//获取上一级目录
// System.getProperty("file.separator") 不同系统下的分隔符

读取Properties文件获取其中的配置属性

Properties properties = new Properties();
properties = PropertiesLoaderUtils.loadAllProperties("/config/config-dev.properties");
//获取文件上传需要存放的文件夹
String fileDownLoad = properties.get("fileDownLoad").toString();

//读取配置文件
Properties properties = new Properties();
String path = FileUtil.class.getClass().getResource("/config/config-dev.properties").getPath();
properties.load(new FileInputStream(path));
//获取文件上传需要存放的文件夹
String fileDownLoad = properties.getProperty("fileDownLoad");

原文地址:https://www.cnblogs.com/zplogo/p/9791194.html