de.dytanic.cloudnet.lib.zip.ZipConverter类的使用及代码示例

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

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

ZipConverter介绍

[英]ZipConverter 2.0
[中]ZipConverter 2.0

代码示例

代码示例来源:origin: Dytanic/CloudNet

public static Path convert(Path zipPath, Path... directories) throws IOException
{
  if (directories == null) return null;
  if (!Files.exists(zipPath))
    Files.createFile(zipPath);
  try (OutputStream outputStream = Files.newOutputStream(zipPath);
     ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream, StandardCharsets.UTF_8))
  {
    for (Path dir : directories)
      if (Files.exists(dir))
        convert0(zipOutputStream, dir);
  }
  return zipPath;
}

代码示例来源:origin: Dytanic/CloudNet

public TemplateLoader unZip(String dest)
{
  try
  {
    ZipConverter.extract(Paths.get(this.dest), Paths.get(dest));
    new File(this.dest).delete();
  } catch (IOException e)
  {
    e.printStackTrace();
  }
  return this;
}

代码示例来源:origin: Dytanic/CloudNet

public static Path extract(byte[] zipData, Path targetDirectory) throws IOException
{
  if (zipData == null || zipData.length == 0 || targetDirectory == null) return targetDirectory;
  try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(zipData))
  {
    extract0(byteArrayInputStream, targetDirectory);
  }
  return targetDirectory;
}

代码示例来源:origin: Dytanic/CloudNet

outputStream.write(ZipConverter.convert(new Path[]{dir}));
outputStream.flush();

代码示例来源:origin: Dytanic/CloudNet

public static void extract0(InputStream inputStream, Path targetDirectory) throws IOException
{
  try (ZipInputStream zipInputStream = new ZipInputStream(inputStream, StandardCharsets.UTF_8))
  {
    ZipEntry zipEntry = null;
    while ((zipEntry = zipInputStream.getNextEntry()) != null)
    {
      extract1(zipInputStream, zipEntry, targetDirectory);
      zipInputStream.closeEntry();
    }
  }
}

代码示例来源:origin: Dytanic/CloudNet

byte[] value = ZipConverter.convert(new Path[]{Paths.get(x)});
  fullHttpResponse.headers().set("content-disposition", "attachment; filename = " + document.getString("template") + ".zip");
  fullHttpResponse.content().writeBytes(value);
byte[] value = ZipConverter.convert(new Path[]{Paths.get(x)});

代码示例来源:origin: Dytanic/CloudNet

public MasterTemplateLoader unZip(String dest)
{
  try
  {
    ZipConverter.extract(Paths.get(this.dest), Paths.get(dest));
    new File(this.dest).delete();
  } catch (IOException e)
  {
    e.printStackTrace();
  }
  return this;
}

代码示例来源:origin: Dytanic/CloudNet

public static Path extract(Path zipPath, Path targetDirectory) throws IOException
{
  if (zipPath == null || targetDirectory == null || !Files.exists(zipPath)) return targetDirectory;
  try (InputStream inputStream = Files.newInputStream(zipPath))
  {
    extract0(inputStream, targetDirectory);
  }
  return targetDirectory;
}

代码示例来源:origin: Dytanic/CloudNet

public static byte[] convert(Path... directories)
{
  if (directories == null) return new byte[0];
  try (ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
     ZipOutputStream zipOutputStream = new ZipOutputStream(byteBuffer, StandardCharsets.UTF_8))
  {
    for (Path dir : directories)
      if (Files.exists(dir))
        convert0(zipOutputStream, dir);
    return byteBuffer.toByteArray();
  } catch (IOException e)
  {
    e.printStackTrace();
  }
  return null;
}

相关文章

ZipConverter类方法