當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。