mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-29 09:38:19 +08:00
🎨 优化部分代码
This commit is contained in:
@ -1,11 +1,16 @@
|
||||
package me.chanjar.weixin.common.util.fs;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Base64;
|
||||
|
||||
import static org.apache.commons.io.FileUtils.openOutputStream;
|
||||
|
||||
public class FileUtils {
|
||||
|
||||
/**
|
||||
@ -20,10 +25,16 @@ public class FileUtils {
|
||||
File resultFile = File.createTempFile(name, '.' + ext, tmpDirFile);
|
||||
|
||||
resultFile.deleteOnExit();
|
||||
org.apache.commons.io.FileUtils.copyToFile(inputStream, resultFile);
|
||||
copyToFile(inputStream, resultFile);
|
||||
return resultFile;
|
||||
}
|
||||
|
||||
private static void copyToFile(final InputStream source, final File destination) throws IOException {
|
||||
try (InputStream in = source; OutputStream out = openOutputStream(destination)) {
|
||||
IOUtils.copy(in, out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建临时文件.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user