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


Java ArchiveEntry.getSize方法代码示例

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


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

示例1: testAdditionalFiles

import org.apache.commons.compress.archivers.ArchiveEntry; //导入方法依赖的package包/类
@Test
public void testAdditionalFiles() throws IOException, ArchiveException {
  Map<String, byte[]> randomFiles = generateRandomFiles(NUM_RANDOM_FILES);
  byte[] packaged = packagingService.packageSubmission(randomFiles);

  createStreams(packaged);

  ArchiveEntry entry = inputArchive.getNextEntry();

  for (; entry != null; entry = inputArchive.getNextEntry()) {
    // Skip template files
    if (templateEntries.contains(entry.getName())) {
      continue;
    }

    assertTrue(randomFiles.containsKey(entry.getName()));

    byte[] expectedContent = randomFiles.get(entry.getName());
    byte[] actualContent = new byte[(int) entry.getSize()];
    inputArchive.read(actualContent);

    assertArrayEquals(expectedContent, actualContent);
  }

}
 
开发者ID:tdd-pingis,项目名称:tdd-pingpong,代码行数:26,代码来源:SubmissionPackagingServiceTest.java

示例2: extractTarOrGZToTempDir

import org.apache.commons.compress.archivers.ArchiveEntry; //导入方法依赖的package包/类
private boolean extractTarOrGZToTempDir(File nestedTempDir, File tar, String virtualPath)  {
    ArchiveInputStream tarInputStream = null;
    try {
        tarInputStream = getArchiveInputStream(tar);
        ArchiveEntry entry;
        while ((entry = tarInputStream.getNextEntry()) != null) {
            String fileName = entry.getName();
            if (!entry.isDirectory() && (isCandidateForSha1(virtualPath + "/" + fileName) || isCandidateForExtract(virtualPath + "/" + fileName))) {
                byte[] buffer = new byte[(int) entry.getSize()];
                tarInputStream.read(buffer, 0, buffer.length);
                FileUtils.writeByteArrayToFile(new File(nestedTempDir +"/" + fileName), buffer);
            }
        }

    } catch (IOException e) {
        listener.getLogger().println("Failed to extract archive: ["+tar.getAbsolutePath()+"]: " + e.getMessage());

    } finally {
        IOUtils.closeQuietly(tarInputStream);
    }

    return nestedTempDir.exists();
}
 
开发者ID:jenkinsci,项目名称:checkmarx-plugin,代码行数:24,代码来源:OSAScanner.java

示例3: ArchiveEntryImpl

import org.apache.commons.compress.archivers.ArchiveEntry; //导入方法依赖的package包/类
public ArchiveEntryImpl(@Nonnull ArchiveEntry... entries) {
    if (entries.length == 0) {
        throw new IllegalArgumentException("Cannot create ZipEntryInfo without a ZipEntry!");
    }

    ArchiveEntry entry = entries[entries.length - 1];

    if (entries.length > 1) {
        StringBuilder fullPath = new StringBuilder();
        for (int i = 0; i < entries.length; i++) {
            fullPath.append(entries[i].getName());
            if (i != entries.length - 1) {
                fullPath.append(RepoPath.ARCHIVE_SEP).append('/');
            }
        }
        this.path = fullPath.toString();
    } else {
        this.path = entry.getName();
    }
    this.name = PathUtils.getFileName(entry.getName());
    this.time = entry.getLastModifiedDate().getTime();
    this.size = entry.getSize();
    this.directory = entry.isDirectory();
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:25,代码来源:ArchiveEntryImpl.java

示例4: untar

import org.apache.commons.compress.archivers.ArchiveEntry; //导入方法依赖的package包/类
public static void untar(
        InputStream tar,
        File parentDir
) throws IOException {
    TarArchiveInputStream tin = new TarArchiveInputStream(tar);
    ArchiveEntry e;
    while ((e = tin.getNextEntry()) != null) {
        File f = new File(parentDir, e.getName());
        f.setLastModified(e.getLastModifiedDate().getTime());
        f.getParentFile().mkdirs();
        if (e.isDirectory()) {
            f.mkdir();
            continue;
        }
        long size = e.getSize();
        checkFileSize(size);
        try (OutputStream out = new FileOutputStream(f)) {
            /* TarInputStream pretends each
               entry's EOF is the stream's EOF */
            IOUtils.copy(tin, out);
        }
    }
}
 
开发者ID:winstonli,项目名称:writelatex-git-bridge,代码行数:24,代码来源:Tar.java

示例5: readArtifactContext

import org.apache.commons.compress.archivers.ArchiveEntry; //导入方法依赖的package包/类
byte[] readArtifactContext(Path input) {
    try (InputStream in = Files.newInputStream(getDeflatedFile(input));
         TarArchiveInputStream tarIn = new TarArchiveInputStream(in)) {
        ArchiveEntry entry = tarIn.getNextEntry();
        while (entry != null) {
            if (ARTIFACT_CONTEXT.equals(entry.getName())) {
                byte[] data = new byte[(int) entry.getSize()];
                tarIn.read(data, 0, data.length);
                return data;
            }
            entry = tarIn.getNextEntry();
        }
    } catch (IOException e) {
        LOG.warn("[{} - {}]: Error extracting tar  {}.", request.getLogName(), request.getId(), e.getMessage());
        throw new IllegalStateException(e);
    }
    throw new IllegalStateException();
}
 
开发者ID:msoute,项目名称:vertx-deploy-tools,代码行数:19,代码来源:GzipExtractor.java


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