//拿到路径
String s1 = new ApplicationHome(this.getClass()).getDir().getParentFile().getParentFile().getAbsolutePath() + "\\src\\main\\resources\\static\\templateFiles\\";
//文件输出流,要求把文件写入s1 + fileName上。
//fileName是真正的、不带路径的文件名
FileOutputStream out = new FileOutputStream(new File(s1 + fileName));
这里我将文件保存到了
\\src\\main\\resources\\static\\templateFiles下,大家可以根据自己要求设置。
最后我们只需要利用out对象,把文件写入到该目录就好了。(记得生成的s1对象并不是完整的文件,应该还要加上文件名最后构成\src\main\resources\static\templateFiles\我的文件.txt)