|
@@ -2,6 +2,7 @@ package com.simuwang.base.common.util;
|
|
|
|
|
|
import cn.hutool.core.exceptions.ExceptionUtil;
|
|
|
import jakarta.mail.Part;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
@@ -56,14 +57,15 @@ public class FileUtil {
|
|
|
}
|
|
|
|
|
|
public static void saveFile(File saveFile, Part part) throws Exception {
|
|
|
- BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(saveFile) );
|
|
|
- byte[] buff = new byte[2048];
|
|
|
+// BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(saveFile) );
|
|
|
+// byte[] buff = new byte[2048];
|
|
|
InputStream is = part.getInputStream();
|
|
|
- int ret = 0;
|
|
|
- while( (ret = is.read(buff)) > 0 ){
|
|
|
- bos.write(buff, 0, ret);
|
|
|
- }
|
|
|
- bos.close();
|
|
|
+// int ret = 0;
|
|
|
+// while( (ret = is.read(buff)) > 0 ){
|
|
|
+// bos.write(buff, 0, ret);
|
|
|
+// }
|
|
|
+ FileUtils.copyInputStreamToFile(is, saveFile);
|
|
|
+// bos.close();
|
|
|
is.close();
|
|
|
}
|
|
|
}
|