本文整理匯總了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();
}