本文整理汇总了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);
}
}
示例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();
}
示例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();
}
示例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);
}
}
}
示例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();
}