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