當前位置: 首頁>>代碼示例>>Java>>正文


Java ZipArchiveEntry.getSize方法代碼示例

本文整理匯總了Java中org.apache.commons.compress.archivers.zip.ZipArchiveEntry.getSize方法的典型用法代碼示例。如果您正苦於以下問題:Java ZipArchiveEntry.getSize方法的具體用法?Java ZipArchiveEntry.getSize怎麽用?Java ZipArchiveEntry.getSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.compress.archivers.zip.ZipArchiveEntry的用法示例。


在下文中一共展示了ZipArchiveEntry.getSize方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getStroomZipNameSet

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
public StroomZipNameSet getStroomZipNameSet() throws IOException {
	if (stroomZipNameSet == null) {
		stroomZipNameSet = new StroomZipNameSet(false);
		Enumeration<ZipArchiveEntry> entryE = getZipFile().getEntries();

		while (entryE.hasMoreElements()) {
			ZipArchiveEntry entry = entryE.nextElement();

			// Skip Dir's
			if (!entry.isDirectory()) {
				String fileName = entry.getName();
				stroomZipNameSet.add(fileName);
			}

			long entrySize = entry.getSize();
			if (entrySize == -1 || totalSize == -1) {
				// Can nolonger sum
			} else {
				totalSize += entrySize;
			}

		}

	}
	return stroomZipNameSet;
}
 
開發者ID:gchq,項目名稱:stroom-agent,代碼行數:27,代碼來源:StroomZipFile.java

示例2: getStroomZipNameSet

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
public StroomZipNameSet getStroomZipNameSet() throws IOException {
    if (stroomZipNameSet == null) {
        stroomZipNameSet = new StroomZipNameSet(false);
        Enumeration<ZipArchiveEntry> entryE = getZipFile().getEntries();

        while (entryE.hasMoreElements()) {
            ZipArchiveEntry entry = entryE.nextElement();

            // Skip Dir's
            if (!entry.isDirectory()) {
                String fileName = entry.getName();
                stroomZipNameSet.add(fileName);
            }

            long entrySize = entry.getSize();
            if (entrySize > 0) {
                totalSize += entrySize;
            }

        }
    }
    return stroomZipNameSet;
}
 
開發者ID:gchq,項目名稱:stroom-proxy,代碼行數:24,代碼來源:StroomZipFile.java

示例3: unZip

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
/** uncompresses a single file content that had zip applied */
private static byte[] unZip(byte[] content) throws IOException {
    // this code only works if we throw an exception above, meaning we can't uncompress with the generalized approach
    try (
            ByteArrayInputStream compressedIn = new ByteArrayInputStream(content);
            ZipArchiveInputStream zipArcInStream = new ZipArchiveInputStream(compressedIn);
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            ) {
        ZipArchiveEntry entry = zipArcInStream.getNextZipEntry();
        long entrySize = entry.getSize();
        final byte[] buffer = new byte[8192];
        int n;
        while ((n = zipArcInStream.read(buffer,0, 8192 )) != -1) {
            out.write(buffer, 0, n);
        }

        byte[] uncompressed = out.toByteArray();
        return uncompressed;
    }
}
 
開發者ID:stucco,項目名稱:collectors,代碼行數:21,代碼來源:UnpackUtils.java

示例4: checkBarFileEntrySize

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
/**
 * barファイル內エントリのファイルサイズチェック.
 * @param zae barファイル內エントリ
 * @param entryName エントリ名
 * @param maxBarEntryFileSize エントリのファイルサイズ
 */
protected void checkBarFileEntrySize(ZipArchiveEntry zae, String entryName,
        long maxBarEntryFileSize) {
    // [400]barファイル內エントリのファイルサイズが上限値を超えている
    if (zae.getSize() > (long) (maxBarEntryFileSize * MB)) {
        String message = "Bar file entry size too large invalid file [%s: %sB]";
        log.info(String.format(message, entryName, String.valueOf(zae.getSize())));
        throw PersoniumCoreException.BarInstall.BAR_FILE_ENTRY_SIZE_TOO_LARGE
                .params(entryName, String.valueOf(zae.getSize()));
    }
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:17,代碼來源:BarFileInstaller.java

示例5: findBestSource

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
/**
 * Find best source.
 *
 * @param source the source
 * @param target the target
 * @param targetEntry the target entry
 * @return the zip archive entry
 * @throws IOException Signals that an I/O exception has occurred.
 */
public ZipArchiveEntry findBestSource(ZipFile source, ZipFile target, ZipArchiveEntry targetEntry) throws IOException {
  ArrayList<ZipArchiveEntry> ret = new ArrayList<>();
  for (ZipArchiveEntry next : source.getEntries(targetEntry.getName())) {
    if (next.getCrc() == targetEntry.getCrc())
      return next;
    ret.add(next);
  }
  if (ret.size() == 0)
    return null;
  if (ret.size() == 1 || targetEntry.isDirectory())
    return ret.get(0);
  //More than one and no matching crc --- need to calculate xdeltas and pick the  shortest
  ZipArchiveEntry retEntry = null;
  for (ZipArchiveEntry sourceEntry : ret) {
    try (ByteArrayOutputStream outbytes = new ByteArrayOutputStream()) {
      Delta d = new Delta();
      DiffWriter diffWriter = new GDiffWriter(new DataOutputStream(outbytes));
      int sourceSize = (int) sourceEntry.getSize();
      byte[] sourceBytes = new byte[sourceSize];
      try (InputStream sourceStream = source.getInputStream(sourceEntry)) {
        for (int erg = sourceStream.read(sourceBytes); erg < sourceBytes.length; erg += sourceStream.read(sourceBytes, erg, sourceBytes.length - erg));
      }
      d.compute(sourceBytes, target.getInputStream(targetEntry), diffWriter);
      byte[] nextDiff = outbytes.toByteArray();
      if (calculatedDelta == null || calculatedDelta.length > nextDiff.length) {
        retEntry = sourceEntry;
        calculatedDelta = nextDiff;
      }
    }
  }
  return retEntry;
}
 
開發者ID:NitorCreations,項目名稱:javaxdelta,代碼行數:42,代碼來源:JarDelta.java

示例6: getApplicationResourceInputStream

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
public static InputStream getApplicationResourceInputStream(FileSystem fs,
    Path appPath,
    String entry)
    throws IOException {
  InputStream is = null;
  FSDataInputStream appStream = null;
  try {
    appStream = fs.open(appPath);
    ZipArchiveInputStream zis = new ZipArchiveInputStream(appStream);
    ZipArchiveEntry zipEntry;
    boolean done = false;
    while (!done && (zipEntry = zis.getNextZipEntry()) != null) {
      if (entry.equals(zipEntry.getName())) {
        int size = (int) zipEntry.getSize();
        if (size != -1) {
          log.info("Reading {} of size {}", zipEntry.getName(),
              zipEntry.getSize());
          byte[] content = new byte[size];
          int offset = 0;
          while (offset < size) {
            offset += zis.read(content, offset, size - offset);
          }
          is = new ByteArrayInputStream(content);
        } else {
          log.debug("Size unknown. Reading {}", zipEntry.getName());
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          while (true) {
            int byteRead = zis.read();
            if (byteRead == -1) {
              break;
            }
            baos.write(byteRead);
          }
          is = new ByteArrayInputStream(baos.toByteArray());
        }
        done = true;
      }
    }
  } finally {
    IOUtils.closeStream(appStream);
  }

  return is;
}
 
開發者ID:apache,項目名稱:incubator-slider,代碼行數:45,代碼來源:SliderUtils.java

示例7: toBytes

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
/**
 * Converts the given zip entry to a byte array.
 *
 * @author S3460
 * @param zipfile the zipfile
 * @param entry the entry
 * @return the byte[]
 * @throws Exception the exception
 */
private byte[] toBytes(ZipFile zipfile, ZipArchiveEntry entry) throws Exception {
  int entrySize = (int) entry.getSize();
  byte[] bytes = new byte[entrySize];
  InputStream entryStream = zipfile.getInputStream(entry);
  for (int erg = entryStream.read(bytes); erg < bytes.length; erg += entryStream.read(bytes, erg, bytes.length - erg));
  return bytes;
}
 
開發者ID:NitorCreations,項目名稱:javaxdelta,代碼行數:17,代碼來源:JarDeltaJarPatcherTest.java

示例8: equal

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
/**
 * Test if the content of two byte arrays is completly identical.
 *
 * @param sourceEntry the source entry
 * @param targetEntry the target entry
 * @return true if source and target contain the same bytes.
 */
public boolean equal(ZipArchiveEntry sourceEntry, ZipArchiveEntry targetEntry) {
  return (sourceEntry.getSize() == targetEntry.getSize()) && (sourceEntry.getCrc() == targetEntry.getCrc());
}
 
開發者ID:NitorCreations,項目名稱:javaxdelta,代碼行數:11,代碼來源:JarDelta.java


注:本文中的org.apache.commons.compress.archivers.zip.ZipArchiveEntry.getSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。