gpt4 book ai didi

jodd.io.ZipUtil.ungzip()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 23:15:42 27 4
gpt4 key购买 nike

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

ZipUtil.ungzip介绍

[英]Decompress gzip archive.
[中]解压缩gzip存档。

代码示例

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

/**
 * Decompress gzip archive.
 */
public static File ungzip(String file) throws IOException {
  return ungzip(new File(file));
}

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

/**
 * Decompress gzip archive.
 */
public static File ungzip(final String file) throws IOException {
  return ungzip(new File(file));
}

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

@Test
void testGzip() throws IOException {
  ZipUtil.gzip(new File(dataRoot, "sb.data"));
  File gzipFile = new File(dataRoot, "sb.data.gz");
  assertTrue(gzipFile.exists());
  FileUtil.move(gzipFile, new File(dataRoot, "sb2.data.gz"));
  ZipUtil.ungzip(new File(dataRoot, "sb2.data.gz"));
  File data = new File(dataRoot, "sb2.data");
  assertTrue(data.exists());
  byte[] data2Bytes = FileUtil.readBytes(data);
  byte[] data1Bytes = FileUtil.readBytes(new File(dataRoot, "sb.data"));
  assertTrue(Arrays.equals(data1Bytes, data2Bytes));
  // cleanup
  FileUtil.delete(new File(dataRoot, "sb2.data"));
  FileUtil.delete(new File(dataRoot, "sb2.data.gz"));
}

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

/**
 * Decompress gzip archive.
 */
public static File ungzip(final String file) throws IOException {
  return ungzip(new File(file));
}

代码示例来源:origin: binarywang/WxJava

private String handleGzipBill(String url, String requestStr) {
 try {
  byte[] responseBytes = this.postForBytes(url, requestStr, false);
  Path tempDirectory = Files.createTempDirectory("bill");
  Path path = Paths.get(tempDirectory.toString(), System.currentTimeMillis() + ".gzip");
  Files.write(path, responseBytes);
  try {
   List<String> allLines = Files.readAllLines(ZipUtil.ungzip(path.toFile()).toPath(), StandardCharsets.UTF_8);
   return Joiner.on("\n").join(allLines);
  } catch (ZipException e) {
   if (e.getMessage().contains("Not in GZIP format")) {
    throw WxPayException.from(BaseWxPayResult.fromXML(new String(responseBytes, StandardCharsets.UTF_8),
     WxPayCommonResult.class));
   } else {
    this.log.error("解压zip文件出错", e);
   }
  }
 } catch (Exception e) {
  this.log.error("解析对账单文件时出错", e);
 }
 return null;
}

代码示例来源:origin: com.github.binarywang/weixin-java-pay

private String handleGzipBill(String url, String requestStr) {
 try {
  byte[] responseBytes = this.postForBytes(url, requestStr, false);
  Path tempDirectory = Files.createTempDirectory("bill");
  Path path = Paths.get(tempDirectory.toString(), System.currentTimeMillis() + ".gzip");
  Files.write(path, responseBytes);
  try {
   List<String> allLines = Files.readAllLines(ZipUtil.ungzip(path.toFile()).toPath(), StandardCharsets.UTF_8);
   return Joiner.on("\n").join(allLines);
  } catch (ZipException e) {
   if (e.getMessage().contains("Not in GZIP format")) {
    throw WxPayException.from(BaseWxPayResult.fromXML(new String(responseBytes, StandardCharsets.UTF_8),
     WxPayCommonResult.class));
   } else {
    this.log.error("解压zip文件出错", e);
   }
  }
 } catch (Exception e) {
  this.log.error("解析对账单文件时出错", e);
 }
 return null;
}

代码示例来源:origin: binarywang/WxJava

private String handleGzipFundFlow(String url, String requestStr) throws WxPayException {
 try {
  byte[] responseBytes = this.postForBytes(url, requestStr, true);
  Path tempDirectory = Files.createTempDirectory("fundFlow");
  Path path = Paths.get(tempDirectory.toString(), System.currentTimeMillis() + ".gzip");
  Files.write(path, responseBytes);
  try {
   List<String> allLines = Files.readAllLines(ZipUtil.ungzip(path.toFile()).toPath(), StandardCharsets.UTF_8);
   return Joiner.on("\n").join(allLines);
  } catch (ZipException e) {
   if (e.getMessage().contains("Not in GZIP format")) {
    throw WxPayException.from(BaseWxPayResult.fromXML(new String(responseBytes, StandardCharsets.UTF_8),
     WxPayCommonResult.class));
   } else {
    this.log.error("解压zip文件出错", e);
    throw new WxPayException("解压zip文件出错");
   }
  }
 } catch (WxPayException wxPayException) {
  throw wxPayException;
 } catch (Exception e) {
  this.log.error("解析对账单文件时出错", e);
  throw new WxPayException("解压zip文件出错");
 }
}

代码示例来源:origin: com.github.binarywang/weixin-java-pay

private String handleGzipFundFlow(String url, String requestStr) throws WxPayException {
 try {
  byte[] responseBytes = this.postForBytes(url, requestStr, true);
  Path tempDirectory = Files.createTempDirectory("fundFlow");
  Path path = Paths.get(tempDirectory.toString(), System.currentTimeMillis() + ".gzip");
  Files.write(path, responseBytes);
  try {
   List<String> allLines = Files.readAllLines(ZipUtil.ungzip(path.toFile()).toPath(), StandardCharsets.UTF_8);
   return Joiner.on("\n").join(allLines);
  } catch (ZipException e) {
   if (e.getMessage().contains("Not in GZIP format")) {
    throw WxPayException.from(BaseWxPayResult.fromXML(new String(responseBytes, StandardCharsets.UTF_8),
     WxPayCommonResult.class));
   } else {
    this.log.error("解压zip文件出错", e);
    throw new WxPayException("解压zip文件出错");
   }
  }
 } catch (WxPayException wxPayException) {
  throw wxPayException;
 } catch (Exception e) {
  this.log.error("解析对账单文件时出错", e);
  throw new WxPayException("解压zip文件出错");
 }
}

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