com.xiaoleilu.hutool.util.ZipUtil.closeEntry()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(1.1k)|赞(0)|评价(0)|浏览(234)

本文整理了Java中com.xiaoleilu.hutool.util.ZipUtil.closeEntry()方法的一些代码示例,展示了ZipUtil.closeEntry()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipUtil.closeEntry()方法的具体详情如下:
包路径:com.xiaoleilu.hutool.util.ZipUtil
类名称:ZipUtil
方法名:closeEntry

ZipUtil.closeEntry介绍

[英]关闭当前Entry,继续下一个Entry
[中]关闭当前进入继续下一个进入

代码示例

代码示例来源:origin: com.xiaoleilu/hutool-core

  1. /**
  2. * 压缩一个目录到Zip
  3. *
  4. * @param path 压缩的路径
  5. * @param out 压缩文件存储对象
  6. * @throws UtilException IO异常
  7. */
  8. private static void zipDir(String path, ZipOutputStream out) throws UtilException {
  9. path = StrUtil.addSuffixIfNot(path, StrUtil.SLASH);
  10. try {
  11. out.putNextEntry(new ZipEntry(path));
  12. } catch (IOException e) {
  13. throw new UtilException(e);
  14. } finally {
  15. closeEntry(out);
  16. }
  17. }

代码示例来源:origin: com.xiaoleilu/hutool-core

  1. /**
  2. * 递归压缩流中的数据,不关闭输入流
  3. *
  4. * @param in 需要压缩的输入流
  5. * @param path 压缩的路径
  6. * @param out 压缩文件存储对象
  7. * @throws UtilException IO异常
  8. */
  9. private static void zip(InputStream in, String path, ZipOutputStream out) throws UtilException {
  10. if(null == in) {
  11. return;
  12. }
  13. try {
  14. out.putNextEntry(new ZipEntry(path));
  15. IoUtil.copy(in, out);
  16. } catch (IOException e) {
  17. throw new UtilException(e);
  18. } finally {
  19. closeEntry(out);
  20. }
  21. }

代码示例来源:origin: com.xiaoleilu/hutool

  1. } finally {
  2. IoUtil.close(in);
  3. closeEntry(out);

相关文章