修复文件上传时java.nio.file.FileAlreadyExistsException

This commit is contained in:
libin 2021-05-08 15:31:16 +08:00
parent 50034301ac
commit 14ea071306
1 changed files with 4 additions and 8 deletions

View File

@ -130,14 +130,10 @@ public class FileUploadUtils
private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
{ {
File desc = new File(uploadDir + File.separator + fileName); File desc = new File(uploadDir + File.separator + fileName);
if (!desc.exists()) {
if (!desc.getParentFile().exists()) if (!desc.getParentFile().exists()) {
{
desc.getParentFile().mkdirs(); desc.getParentFile().mkdirs();
} }
if (!desc.exists())
{
desc.createNewFile();
} }
return desc; return desc;
} }