gpt4 book ai didi

jodd.io.ZipBuilder类的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 22:11:31 35 4
gpt4 key购买 nike

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

ZipBuilder介绍

[英]ZIP builder class for building both files or in-memory zips.
[中]ZIP builder类,用于构建两个文件或内存中的ZIP。

代码示例

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

/**
 * Zips a file or a folder. If adding a folder, all its content will be added.
 */
public static File zip(File file) throws IOException {
  String zipFile = file.getAbsolutePath() + ZIP_EXT;
  return ZipBuilder.createZipFile(zipFile)
        .add(file).recursive().save()
      .toZipFile();
}

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

public static ZipBuilder createZipInMemory() {
  return new ZipBuilder();
}

代码示例来源:origin: oblac/jodd

@Test
void testZipBuilderFileMemory() throws IOException {
  byte[] bytes = ZipBuilder.createZipInMemory()
    .add(new File(dataRoot, "sb.data"))
      .path("sbdata").comment("This is sb data file").save()
    .add(new File(dataRoot, "file"))
      .path("folder").comment("This is a folder and all its files").save()
    .add("text")
      .path("folder/txt").save()
    .addFolder("folder2")
    .add("txet")
      .path("folder2/txt2").save()
    .toBytes();

代码示例来源:origin: oblac/jodd

@Test
void testZipEmptyFolder() throws IOException {
  byte[] bytes = ZipBuilder
    .createZipInMemory()
    .addFolder("myEmptyFolder")
    .toBytes();
  File tempDir = FileUtil.createTempDirectory();
  tempDir.deleteOnExit();
  File zipFile = new File(tempDir, "test.zip");
  FileUtil.writeBytes(zipFile, bytes);
  // read zip
  List<String> entries = ZipUtil.listZip(zipFile);
  assertEquals(1, entries.size());
  assertEquals("myEmptyFolder/", entries.get(0));
}

代码示例来源:origin: oblac/jodd

/**
 * Zips a file or a folder. If adding a folder, all its content will be added.
 */
public static File zip(final File file) throws IOException {
  String zipFile = file.getAbsolutePath() + ZIP_EXT;
  return ZipBuilder.createZipFile(zipFile)
        .add(file).recursive().save()
      .toZipFile();
}

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

public static ZipBuilder createZipFile(File zipFile) throws IOException {
  return new ZipBuilder(zipFile);
}
public static ZipBuilder createZipFile(String zipFile) throws IOException {

代码示例来源:origin: oblac/jodd

@Test
void testZipBuilderFile() throws IOException {
  File zipFile = new File(dataRoot, "test.zip");
  ZipBuilder.createZipFile(zipFile)
    .add(new File(dataRoot, "sb.data"))
      .path("sbdata").comment("This is sb data file").save()
    .add(new File(dataRoot, "file"))
      .path("folder").comment("This is a folder and all its files").save()
    .toZipFile();
  assertTrue(zipFile.exists());
  ZipUtil.unzip(zipFile, new File(dataRoot), "sbda*");
  assertTrue(new File(dataRoot, "sbdata").exists());
  assertFalse(new File(dataRoot, "folder").exists());
  ZipUtil.unzip(zipFile, new File(dataRoot));
  assertTrue(new File(dataRoot, "sbdata").exists());
  assertTrue(new File(dataRoot, "folder").exists());
  assertTrue(new File(new File(dataRoot, "folder"), "a.png").exists());
  // cleanup
  FileUtil.delete(new File(dataRoot, "sbdata"));
  FileUtil.deleteDir(new File(dataRoot, "folder"));
  FileUtil.delete(zipFile);
}

代码示例来源:origin: oblac/jodd

public static ZipBuilder createZipFile(final File zipFile) throws IOException {
  return new ZipBuilder(zipFile);
}
public static ZipBuilder createZipFile(final String zipFile) throws IOException {

代码示例来源:origin: org.jodd/jodd-core

/**
 * Zips a file or a folder. If adding a folder, all its content will be added.
 */
public static File zip(final File file) throws IOException {
  String zipFile = file.getAbsolutePath() + ZIP_EXT;
  return ZipBuilder.createZipFile(zipFile)
        .add(file).recursive().save()
      .toZipFile();
}

代码示例来源:origin: oblac/jodd

public static ZipBuilder createZipInMemory() {
  return new ZipBuilder();
}

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

public static ZipBuilder createZipFile(String zipFile) throws IOException {
  return new ZipBuilder(new File(zipFile));
}

代码示例来源:origin: oblac/jodd

public static ZipBuilder createZipFile(final String zipFile) throws IOException {
  return new ZipBuilder(new File(zipFile));
}

代码示例来源:origin: org.jodd/jodd-core

public static ZipBuilder createZipFile(final File zipFile) throws IOException {
  return new ZipBuilder(zipFile);
}
public static ZipBuilder createZipFile(final String zipFile) throws IOException {

代码示例来源:origin: org.jodd/jodd-core

public static ZipBuilder createZipInMemory() {
  return new ZipBuilder();
}

代码示例来源:origin: org.jodd/jodd-core

public static ZipBuilder createZipFile(final String zipFile) throws IOException {
  return new ZipBuilder(new File(zipFile));
}

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com