修复文件上传时java.nio.file.FileAlreadyExistsException
正在显示
1 个修改的文件
包含
4 行增加
和
8 行删除
| @@ -130,14 +130,10 @@ public class FileUploadUtils | @@ -130,14 +130,10 @@ public class FileUploadUtils | ||
| 130 | private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException | 130 | private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException |
| 131 | { | 131 | { |
| 132 | File desc = new File(uploadDir + File.separator + fileName); | 132 | File desc = new File(uploadDir + File.separator + fileName); |
| 133 | - | ||
| 134 | - if (!desc.getParentFile().exists()) | ||
| 135 | - { | ||
| 136 | - desc.getParentFile().mkdirs(); | ||
| 137 | - } | ||
| 138 | - if (!desc.exists()) | ||
| 139 | - { | ||
| 140 | - desc.createNewFile(); | 133 | + if (!desc.exists()) { |
| 134 | + if (!desc.getParentFile().exists()) { | ||
| 135 | + desc.getParentFile().mkdirs(); | ||
| 136 | + } | ||
| 141 | } | 137 | } |
| 142 | return desc; | 138 | return desc; |
| 143 | } | 139 | } |
-
请 注册 或 登录 后发表评论