azkaban.utils.Utils.zipFile()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(169)

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

Utils.zipFile介绍

暂无

代码示例

代码示例来源:origin: azkaban/azkaban

public static void zip(final File input, final File output) throws IOException {
 final FileOutputStream out = new FileOutputStream(output);
 final ZipOutputStream zOut = new ZipOutputStream(out);
 try {
  zipFile("", input, zOut);
 } finally {
  zOut.close();
 }
}

代码示例来源:origin: azkaban/azkaban

public static void zipFolderContent(final File folder, final File output)
  throws IOException {
 final FileOutputStream out = new FileOutputStream(output);
 final ZipOutputStream zOut = new ZipOutputStream(out);
 try {
  final File[] files = folder.listFiles();
  if (files != null) {
   for (final File f : files) {
    zipFile("", f, zOut);
   }
  }
 } finally {
  zOut.close();
 }
}

代码示例来源:origin: azkaban/azkaban

private static void zipFile(final String path, final File input, final ZipOutputStream zOut)
  throws IOException {
 if (input.isDirectory()) {
  final File[] files = input.listFiles();
  if (files != null) {
   for (final File f : files) {
    final String childPath =
      path + input.getName() + (f.isDirectory() ? "/" : "");
    zipFile(childPath, f, zOut);
   }
  }
 } else {
  final String childPath =
    path + (path.length() > 0 ? "/" : "") + input.getName();
  final ZipEntry entry = new ZipEntry(childPath);
  zOut.putNextEntry(entry);
  final InputStream fileInputStream =
    new BufferedInputStream(new FileInputStream(input));
  try {
   IOUtils.copy(fileInputStream, zOut);
  } finally {
   fileInputStream.close();
  }
 }
}

代码示例来源:origin: com.linkedin.azkaban/az-core

public static void zip(final File input, final File output) throws IOException {
 final FileOutputStream out = new FileOutputStream(output);
 final ZipOutputStream zOut = new ZipOutputStream(out);
 try {
  zipFile("", input, zOut);
 } finally {
  zOut.close();
 }
}

代码示例来源:origin: com.linkedin.azkaban/azkaban

public static void zip(File input, File output) throws IOException {
  FileOutputStream out = new FileOutputStream(output);
  ZipOutputStream zOut = new ZipOutputStream(out);
  zipFile("", input, zOut);
  zOut.close();
}

代码示例来源:origin: com.linkedin.azkaban/azkaban

public static void zipFolderContent(File folder, File output) throws IOException {
  FileOutputStream out = new FileOutputStream(output);
  ZipOutputStream zOut = new ZipOutputStream(out);
  File[] files = folder.listFiles();
  if (files != null) {
    for (File f : files) {
      zipFile("", f, zOut);
    }
  }
  zOut.close();
}

代码示例来源:origin: com.linkedin.azkaban/az-core

public static void zipFolderContent(final File folder, final File output)
  throws IOException {
 final FileOutputStream out = new FileOutputStream(output);
 final ZipOutputStream zOut = new ZipOutputStream(out);
 try {
  final File[] files = folder.listFiles();
  if (files != null) {
   for (final File f : files) {
    zipFile("", f, zOut);
   }
  }
 } finally {
  zOut.close();
 }
}

代码示例来源:origin: com.linkedin.azkaban/azkaban

private static void zipFile(String path, File input, ZipOutputStream zOut) throws IOException {
  if (input.isDirectory()) {
    File[] files = input.listFiles();
    if (files != null) {
      for (File f : files) {
        String childPath = path + input.getName()
            + (f.isDirectory() ? "/" : "");
        zipFile(childPath, f, zOut);
      }
    }
  } else {
    String childPath = path + (path.length() > 0 ? "/" : "")
        + input.getName();
    ZipEntry entry = new ZipEntry(childPath);
    zOut.putNextEntry(entry);
    InputStream fileInputStream = new BufferedInputStream(
        new FileInputStream(input));
    IOUtils.copy(fileInputStream, zOut);
    fileInputStream.close();
  }
}

代码示例来源:origin: com.linkedin.azkaban/az-core

private static void zipFile(final String path, final File input, final ZipOutputStream zOut)
  throws IOException {
 if (input.isDirectory()) {
  final File[] files = input.listFiles();
  if (files != null) {
   for (final File f : files) {
    final String childPath =
      path + input.getName() + (f.isDirectory() ? "/" : "");
    zipFile(childPath, f, zOut);
   }
  }
 } else {
  final String childPath =
    path + (path.length() > 0 ? "/" : "") + input.getName();
  final ZipEntry entry = new ZipEntry(childPath);
  zOut.putNextEntry(entry);
  final InputStream fileInputStream =
    new BufferedInputStream(new FileInputStream(input));
  try {
   IOUtils.copy(fileInputStream, zOut);
  } finally {
   fileInputStream.close();
  }
 }
}

相关文章