org.zeroturnaround.zip.ZipUtil.unpackEntry()方法的使用及代码示例

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

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

ZipUtil.unpackEntry介绍

[英]Unpacks a single entry from a ZIP file.
[中]从ZIP文件中解压单个条目。

代码示例

代码示例来源:origin: zeroturnaround/zt-zip

/**
 * Unpacks a single file from a ZIP archive to a file.
 *
 * @param zip
 *          ZIP file.
 * @param name
 *          entry name.
 * @param file
 *          target file to be created or overwritten.
 * @return <code>true</code> if the entry was found and unpacked,
 *         <code>false</code> if the entry was not found.
 */
public static boolean unpackEntry(File zip, String name, File file) {
 return unpackEntry(zip, name, file, null);
}

代码示例来源:origin: zeroturnaround/zt-zip

/**
 * Alias to ZipUtil.getEntry()
 *
 * @param name
 *          name of the entry to fetch bytes from
 * @return byte[]
 *           contents of the entry by given name
 */
public byte[] getEntry(String name) {
 if (src == null) {
  throw new IllegalStateException("Source is not given");
 }
 return ZipUtil.unpackEntry(src, name);
}

代码示例来源:origin: org.hswebframework/hsweb-expands-compress

public void unpack(String entryName, File to) throws IOException {
  ZipUtil.unpackEntry(zipFile, entryName, to);
}

代码示例来源:origin: hs-web/hsweb-expands

public void unpack(String entryName, File to) throws IOException {
  ZipUtil.unpackEntry(zipFile, entryName, to);
}

代码示例来源:origin: org.zeroturnaround/zt-zip

/**
 * Unpacks a single file from a ZIP archive to a file.
 *
 * @param zip
 *          ZIP file.
 * @param name
 *          entry name.
 * @param file
 *          target file to be created or overwritten.
 * @return <code>true</code> if the entry was found and unpacked,
 *         <code>false</code> if the entry was not found.
 */
public static boolean unpackEntry(File zip, String name, File file) {
 return unpackEntry(zip, name, file, null);
}

代码示例来源:origin: hs-web/hsweb-expands

public InputStream read(String entryName) {
  byte[] data = ZipUtil.unpackEntry(zipFile, entryName);
  Objects.requireNonNull(data, entryName);
  return new ByteArrayInputStream(data);
}

代码示例来源:origin: cinchapi/concourse

/**
 * Get the content for the entry at {@code relativeEntryPath} from within
 * the zip file.
 * 
 * @param zipPath the path to the zip file
 * @param relativeEntryPath the path of the entry to extract
 * @return the content of the entry as a {@link ByteBuffer}
 */
public static ByteBuffer getEntryContent(String zipFile,
    String relativeEntryPath) {
  return ByteBuffer.wrap(
      ZipUtil.unpackEntry(new File(zipFile), relativeEntryPath));
}

代码示例来源:origin: org.zeroturnaround/zt-zip

/**
 * Alias to ZipUtil.getEntry()
 *
 * @param name
 *          name of the entry to fetch bytes from
 * @return byte[]
 *           contents of the entry by given name
 */
public byte[] getEntry(String name) {
 if (src == null) {
  throw new IllegalStateException("Source is not given");
 }
 return ZipUtil.unpackEntry(src, name);
}

代码示例来源:origin: org.hswebframework/hsweb-expands-compress

public InputStream read(String entryName) {
  byte[] data = ZipUtil.unpackEntry(zipFile, entryName);
  Objects.requireNonNull(data, entryName);
  return new ByteArrayInputStream(data);
}

代码示例来源:origin: open-eid/SiVa

static boolean isXroadAsiceContainer(UploadedFile validationRequest) throws IOException {
  String document = validationRequest.getEncodedFile();
  if (document == null) {
    return false;
  }
  try (InputStream stream = new ByteArrayInputStream(Base64.decodeBase64(document.getBytes()))) {
    byte[] fileContents = ZipUtil.unpackEntry(stream, UNIQUE_XROAD_ASICE_FILE);
    if (fileContents == null) {
      return false;
    }
    String messageFile = new String(fileContents);
    return messageFile.contains(XROAD_XSD);
  }
}

代码示例来源:origin: PlayPen/playpen-core

public P3Package readPackage(File file) throws PackageException {
  try {
    if (!ZipUtil.containsEntry(file, "package.json")) {
      throw new PackageException("No package schema found");
    }
    byte[] schemaBytes = ZipUtil.unpackEntry(file, "package.json");
    String schemaString = new String(schemaBytes);
    JSONObject schema = new JSONObject(schemaString);
    P3Package p3 = readSchema(schema);
    p3.setLocalPath(file.getPath());
    return p3;
  }
  catch(JSONException e) {
    throw new PackageException("Invalid package schema", e);
  }
}

代码示例来源:origin: PlayPen/playpen-core

byte[] schemaBytes = ZipUtil.unpackEntry(jarFile, "plugin.json");
String schemaString = new String(schemaBytes);
  byte[] fileBytes = null;
  if (!pluginFile.exists()) {
    fileBytes = ZipUtil.unpackEntry(jarFile, filename);
    try {
      Files.write(pluginFile.toPath(), fileBytes);

代码示例来源:origin: spring-projects/spring-integration-extensions

@Test
public void zipStringToFile() throws IOException {
  final ZipTransformer zipTransformer = new ZipTransformer();
  zipTransformer.setBeanFactory(mock(BeanFactory.class));
  zipTransformer.afterPropertiesSet();
  final String stringToCompress = "Hello World";
  final String zipEntryFileName = "test.txt";
  final Message<String> message = MessageBuilder.withPayload(stringToCompress)
    .setHeader(ZipHeaders.ZIP_ENTRY_FILE_NAME, zipEntryFileName)
    .build();
  final Message<?> result = zipTransformer.transform(message);
  Assert.assertTrue("Expected payload to be an instance of file but was "
      + result.getPayload().getClass().getName(), result.getPayload() instanceof File);
  final File payload = (File) result.getPayload();
  System.out.println(payload.getAbsolutePath());
  Assert.assertEquals(message.getHeaders().getId().toString() + ".msg.zip", payload.getName());
  Assert.assertTrue(SpringZipUtils.isValid(payload));
  final byte[] zipEntryData = ZipUtil.unpackEntry(payload, "test.txt");
  Assert.assertNotNull("Entry '" + zipEntryFileName + "' was not found.", zipEntryData);
  Assert.assertTrue("Hello World".equals(new String(zipEntryData)));
}

代码示例来源:origin: fgl27/isu

ZipUtil.unpackEntry(new File(zip_file), "logcat.txt", new File(tmplogcat));
if (compareFiles(logcat, tmplogcat, true, mContext)) {
  Log.d(TAG, "ziped logcat.txt is ok");

相关文章