当前位置: 首页>>代码示例>>Java>>正文


Java ZipUtil.iterate方法代码示例

本文整理汇总了Java中org.zeroturnaround.zip.ZipUtil.iterate方法的典型用法代码示例。如果您正苦于以下问题:Java ZipUtil.iterate方法的具体用法?Java ZipUtil.iterate怎么用?Java ZipUtil.iterate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.zeroturnaround.zip.ZipUtil的用法示例。


在下文中一共展示了ZipUtil.iterate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test

import org.zeroturnaround.zip.ZipUtil; //导入方法依赖的package包/类
@Test
public void test() throws IOException {
	PackageWriter packageWriter = new DefaultPackageWriter();
	Package pkgtoWrite = createSimplePackage();
	Path tempPath = Files.createTempDirectory("tests");
	File outputDirectory = tempPath.toFile();

	File zipFile = packageWriter.write(pkgtoWrite, outputDirectory);
	assertThat(zipFile).exists();
	assertThat(zipFile.getName()).isEqualTo("myapp-1.0.0.zip");
	ZipUtil.iterate(zipFile, new ZipEntryCallback() {
		@Override
		public void process(InputStream inputStream, ZipEntry zipEntry) throws IOException {
			if (zipEntry.getName().equalsIgnoreCase("package.yml")) {
				assertExpectedContents(inputStream, "package.yml");
			}
			if (zipEntry.getName().equalsIgnoreCase("values.yml")) {
				assertExpectedContents(inputStream, "values.yml");
			}
			if (zipEntry.getName().equals("myapp.yml")) {
				assertExpectedContents(inputStream, "generic-template.yml");
			}
		}
	});
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:26,代码来源:PackageWriterTests.java

示例2: compareOfflineAndOnline

import org.zeroturnaround.zip.ZipUtil; //导入方法依赖的package包/类
public Map<String, List<Map<File, String>>> compareOfflineAndOnline(String onlineZipPath, String offlineDirPath) {

        File existFolder = new File(offlineDirPath);
        if (!existFolder.exists()) {
            return null;
        }
        Map<String, List<Map<File,String>>> result = new HashMap<>();
        result.put("update", new ArrayList<>());
        result.put("add", new ArrayList<>());
        ZipUtil.iterate(new File(onlineZipPath), new ZipEntryCallback() {
            @Override
            public void process(InputStream in, ZipEntry zipEntry) throws IOException {
                File fileOffline = new File(existFolder,zipEntry.getName());
                if(fileOffline.exists()) { // file for merge
                    if(zipEntry.getCrc() != getCrc(fileOffline.getAbsolutePath())) {
                        result.get("update").add(inputToMapping(in, fileOffline));
                    }
                } else { // file for add
                    result.get("add").add(inputToMapping(in, fileOffline));
                }
            }
        });
        return result;
    }
 
开发者ID:firm1,项目名称:zest-writer,代码行数:25,代码来源:DownloadContentService.java

示例3: extractZIP

import org.zeroturnaround.zip.ZipUtil; //导入方法依赖的package包/类
/**
 * Extract workflows from an archive
 * @param byteArrayArchive the archive as byte array
 * @return the list of Workflows byte arrays
 */
public List<byte[]> extractZIP(byte[] byteArrayArchive) {

    List<byte[]> filesList = new ArrayList<>();
    if (byteArrayArchive == null) {
        return filesList;
    }

    try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayArchive)) {
        ZipUtil.iterate(byteArrayInputStream, (in, zipEntry) -> process(in, zipEntry, filesList));
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

    return filesList;
}
 
开发者ID:ow2-proactive,项目名称:workflow-catalog-old,代码行数:21,代码来源:ArchiveManagerHelper.java

示例4: testAllGamesFromArchive

import org.zeroturnaround.zip.ZipUtil; //导入方法依赖的package包/类
@Test
public void testAllGamesFromArchive() {
  Path path = Paths.get("src/test/resources/games-aeb-cwi-nl.zip");
  ZipUtil.iterate(path.toFile(), new ZipEntryCallback() {

    @Override
    public void process(InputStream in, ZipEntry zipEntry) throws IOException {
      if (zipEntry.toString().endsWith("sgf")) {

        try {
          Sgf.createFromInputStream(in);
        }
        catch (SgfParseException e) {
          System.out.println("Problem with " + zipEntry.getName());
          e.printStackTrace();
          Assert.fail();
        }
      }
    }
  });
  Assert.assertTrue(true);
}
 
开发者ID:toomasr,项目名称:sgf4j,代码行数:23,代码来源:TestAebSet.java

示例5: processZip

import org.zeroturnaround.zip.ZipUtil; //导入方法依赖的package包/类
private void processZip(final String zipName,
                        final Map<String, ClassInfo> foundClasses) {
  final File zip = new File(zipName);
  ZipUtil.iterate(zip, new ZipEntryCallback() {
    public void process(InputStream in, ZipEntry zipEntry) throws IOException {
      if ((!zipEntry.isDirectory()) && (zipEntry.getName().endsWith(".class"))) {
        try {
          log.trace("Loading " + zipName + "(" + zipEntry.getName() + ")");
          loadClassData(in, new ClassInfoClassVisitor(foundClasses, zip));
        } catch (ClassFinderException ex) {
          log.error("Can't open \"" + zipEntry.getName() + "\" in file \"" + zipName + "\": ", ex);
        }
      }
    }
  });
}
 
开发者ID:poolik,项目名称:classfinder,代码行数:17,代码来源:ParallelClassLoader.java

示例6: extractFromZip

import org.zeroturnaround.zip.ZipUtil; //导入方法依赖的package包/类
/**
 * Extract files from zip archive, not recursive.
 *
 * @param uploadedFile uploaded zip file
 * @return collection of zip files.
 */
private Collection<UserFile> extractFromZip(UploadedFile uploadedFile) {
    LOGGER.info("Start extraction from zip file with name=" + uploadedFile.getName());
    final List<UserFile> userFiles = new ArrayList<UserFile>();
    ZipUtil.iterate(new ByteArrayInputStream(uploadedFile.getContent().getFileContent()), new ZipEntryCallback() {
        @Override
        public void process(InputStream inputStream, ZipEntry zipEntry) throws IOException {
            if (!zipEntry.isDirectory()) {
                byte[] content = IOUtils.toByteArray(inputStream);
                String xmlSchema = defaultString(xmlSchemaExtractor.extractXmlSchema(content), DUMMY_XML_SCHEMA);
                userFiles.add(new UserFile(new UploadedFile(zipEntry.getName(), content), xmlSchema));
            }
        }
    });
    LOGGER.info("Extracted " + userFiles.size() + " from zip archive.");
    return userFiles;
}
 
开发者ID:eea,项目名称:eionet.webq,代码行数:23,代码来源:MultipartFileToUserFileConverter.java

示例7: copySigarLibs

import org.zeroturnaround.zip.ZipUtil; //导入方法依赖的package包/类
private void copySigarLibs(final File libDirectory, File sigarDistributionFile)
        throws MojoExecutionException {
    try {
        ZipUtil.iterate(sigarDistributionFile, new ZipEntryCallback() {
            @Override
            public void process(InputStream in, ZipEntry zipEntry) throws IOException {
                String zipEntryName = zipEntry.getName();
                if (zipEntryName.contains("sigar-bin/lib") && !zipEntryName.endsWith("/")) {
                    String compressedFileName = zipEntryName.substring(zipEntryName.lastIndexOf("/") + 1);
                    if (compressedFileName.endsWith(".so") || compressedFileName.endsWith(".dll") ||
                            compressedFileName.endsWith(".sl") || compressedFileName.endsWith(".dylib")
                            || compressedFileName.equals("sigar.jar")) {
                        File destinationFile = new File(libDirectory, compressedFileName);
                        copyStreamToFile(new RawInputStreamFacade(in), destinationFile);
                    }
                }
            }
        });
    } catch (Exception e) {
        throw new MojoExecutionException("Could not unpack Sigar file " + sigarDistributionFile
                .getAbsolutePath(), e);
    }
}
 
开发者ID:rhq-project,项目名称:rhq-agent-plugin-plugin,代码行数:24,代码来源:SetupTestPluginContainerMojo.java

示例8: assertZipWithFileHierarchy

import org.zeroturnaround.zip.ZipUtil; //导入方法依赖的package包/类
private void assertZipWithFileHierarchy(Path archivePath) {
    final int[] nbEntries = { 0 };

    // Reads ZIP content using a third-party library
    ZipUtil.iterate(archivePath.toFile(), new ZipEntryCallback() {
        @Override
        public void process(InputStream in, ZipEntry zipEntry) throws IOException {
            nbEntries[0]++;
        }
    });

    assertThat(nbEntries[0]).isEqualTo(HIERARCHY_DEPTH + 1);
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:14,代码来源:VFSZipperZIPTest.java

示例9: getMinimizedEntries

import org.zeroturnaround.zip.ZipUtil; //导入方法依赖的package包/类
private ZipEntrySource[] getMinimizedEntries(File minimizedJarFile, String currentArtifactFileName) {
    final Set<ZipEntrySource> resultEntriesSet = Sets.newHashSet();
    ZipUtil.iterate(minimizedJarFile, new ZipEntryCallback() {

        public void process(InputStream in, ZipEntry minimizedEntry) throws IOException {
            final String minimizedEntryName = minimizedEntry.getName();
            resultEntriesSet.add(new ByteSource(minimizedEntryName, readBytes(in)));
        }
    });
    return resultEntriesSet.toArray(new ZipEntrySource[resultEntriesSet.size()]);
}
 
开发者ID:Codarama,项目名称:diet-maven-mojo,代码行数:12,代码来源:JarArtifactPackager.java

示例10: getCurrentArtifactNames

import org.zeroturnaround.zip.ZipUtil; //导入方法依赖的package包/类
private Set<String> getCurrentArtifactNames(File currentArtifactFile) {
    final Set<String> result = Sets.newHashSet();
    ZipUtil.iterate(currentArtifactFile, new ZipEntryCallback() {

        public void process(InputStream in, ZipEntry currentEntry) throws IOException {
            result.add(currentEntry.getName());
        }
    });

    return result;
}
 
开发者ID:Codarama,项目名称:diet-maven-mojo,代码行数:12,代码来源:JarArtifactPackager.java


注:本文中的org.zeroturnaround.zip.ZipUtil.iterate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。