|
@@ -132,12 +132,20 @@ public abstract class CommonUtil {
|
|
|
zos.putNextEntry(new ZipEntry(name));
|
|
|
// copy文件到zip输出流中
|
|
|
int len;
|
|
|
- FileInputStream in = new FileInputStream(sourceFile);
|
|
|
- while ((len = in.read(buf)) != -1) {
|
|
|
- zos.write(buf, 0, len);
|
|
|
+ FileInputStream in = null;
|
|
|
+ try {
|
|
|
+ in = new FileInputStream(sourceFile);
|
|
|
+ while ((len = in.read(buf)) != -1) {
|
|
|
+ zos.write(buf, 0, len);
|
|
|
+ }
|
|
|
+ zos.closeEntry();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (in != null) {
|
|
|
+ in.close();
|
|
|
+ }
|
|
|
}
|
|
|
- zos.closeEntry();
|
|
|
- in.close();
|
|
|
} else {
|
|
|
File[] listFiles = sourceFile.listFiles();
|
|
|
if (listFiles == null || listFiles.length == 0) {
|