法规技术评估-导出反馈结果压缩包接口。

提取复制文件工具类。
This commit is contained in:
wangzhijiang
2022-07-14 15:14:53 +08:00
parent a9533f2d18
commit ace70bd93b
9 changed files with 289 additions and 21 deletions
@@ -0,0 +1,34 @@
package com.jero.common.util;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class FileUtils {
/**
* 复制文件
* @param in
* @param newFile
* @throws IOException
*/
public static void copyFile(InputStream in, String newFile) throws IOException {
File file2 = new File(newFile);
if (!file2.exists()) {
file2.createNewFile();
}
try (FileOutputStream ou = new FileOutputStream(newFile);) {
byte[] bs = new byte[1024];
int count = 0;
while ((count = in.read(bs, 0, bs.length)) != -1) {
ou.write(bs, 0, count);
}
ou.flush();
} catch (IOException e) {
e.printStackTrace();
throw new IOException("复制文件失败!");
} finally {
in.close();
}
}
}