//将文件移动到指定目录
try {
File startFile = new File("D:\studyPlat2020\"+tblQuestionEnglish.getUploadPath().substring(0,tblQuestionEnglish.getUploadPath().lastIndexOf("\")));//获取源文件夹路径
File tmpFile = new File("D:\studyPlat2020\target\"+tblQuestionEnglish.getUploadPath().substring(0,tblQuestionEnglish.getUploadPath().lastIndexOf("\")));//创建目标文件夹路径
if (!tmpFile.exists()) {//判断文件夹是否创建,没有创建则创建新文件夹
tmpFile.mkdirs();
}
if(startFile.exists()){
for (File f : startFile.listFiles()) {
if (f.renameTo(new File("D:\studyPlat2020\target\"+tblQuestionEnglish.getUploadPath()+f.getName()))) {
// System.out.println("文件移动成功!");
} else {
System.out.println(tblQuestionEnglish.getUploadPath()+f+"文件移动失败!");
}
}
}
} catch (Exception e) {
System.out.println(e);
}