显示正在占用

本来以为是哪个读写流忘了close,结果都检查后也没发现。

解决:除了关闭读写流,还要清除gc...

finally {
            try {
                zipOutputStream.closeEntry();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                zipOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                fileInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            System.gc();//否则源文件删除时可能有问题
        }

 

相关文章: