法规技术评估-导出反馈结果压缩包接口。
提取复制文件工具类。
This commit is contained in:
+34
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user