|
|
|
@@ -234,27 +234,21 @@ public class FileUtil extends cn.hutool.core.io.FileUtil { |
|
|
|
destFile.delete(); |
|
|
|
} |
|
|
|
//将文件合并 |
|
|
|
FileOutputStream fos = null; |
|
|
|
try { |
|
|
|
fos = new FileOutputStream(destFile); |
|
|
|
try (FileOutputStream fos = new FileOutputStream(destFile)) { |
|
|
|
for (File file : files) { |
|
|
|
logger.info("merge file:{},fileSize:{}", file.getAbsolutePath(),FileUtil.size(file)); |
|
|
|
FileInputStream fis = new FileInputStream(file); |
|
|
|
byte[] bytes = new byte[1024]; |
|
|
|
int len = 0; |
|
|
|
while ((len = fis.read(bytes)) != -1) { |
|
|
|
fos.write(bytes, 0, len); |
|
|
|
try (FileInputStream fis = new FileInputStream(file);){ |
|
|
|
byte[] bytes = new byte[1024]; |
|
|
|
int len = 0; |
|
|
|
while ((len = fis.read(bytes)) != -1) { |
|
|
|
fos.write(bytes, 0, len); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
fis.close(); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} finally { |
|
|
|
try { |
|
|
|
fos.close(); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|