org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(269)

本文整理了Java中org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.<init>()方法的一些代码示例,展示了ZipArchiveInputStream.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipArchiveInputStream.<init>()方法的具体详情如下:
包路径:org.apache.commons.compress.archivers.zip.ZipArchiveInputStream
类名称:ZipArchiveInputStream
方法名:<init>

ZipArchiveInputStream.<init>介绍

[英]Create an instance using UTF-8 encoding
[中]使用UTF-8编码创建实例

代码示例

代码示例来源:origin: jphp-group/jphp

@Signature
public void __construct(InputStream inputStream, String encoding) {
  __wrappedObject = new ZipArchiveInputStream(inputStream, encoding != null && encoding.isEmpty() ? null : encoding);
}

代码示例来源:origin: jphp-group/jphp

@Override
protected PArchiveInput createInput(Environment env) {
  return new PZipArchiveInput(env, new ZipArchiveInputStream(Stream.getInputStream(env, getSource())));
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * Opens the specified stream as a secure zip
 *
 * @param stream
 *            The stream to open.
 * @return The zip stream freshly open.
 */
@SuppressWarnings("resource")
public static ZipArchiveThresholdInputStream openZipStream(InputStream stream) throws IOException {
  // Peek at the first few bytes to sanity check
  InputStream checkedStream = FileMagic.prepareToCheckMagic(stream);
  verifyZipHeader(checkedStream);
  
  // Open as a proper zip stream
  return new ZipArchiveThresholdInputStream(new ZipArchiveInputStream(checkedStream));
}

代码示例来源:origin: cSploit/android

/**
 * open an Archive InputStream
 * @param in the InputStream to the archive
 * @return the ArchiveInputStream to read from
 * @throws IOException if an I/O error occurs
 * @throws java.lang.IllegalStateException if no archive method has been choose
 */
private ArchiveInputStream openArchiveStream(InputStream in) throws IOException, IllegalStateException {
 switch (mCurrentTask.archiver) {
  case tar:
   return new TarArchiveInputStream(new BufferedInputStream(openCompressedStream(in)));
  case zip:
   return new ZipArchiveInputStream(new BufferedInputStream(openCompressedStream(in)));
  default:
   throw new IllegalStateException("trying to open an archive, but no archive algorithm selected.");
 }
}

代码示例来源:origin: jeremylong/DependencyCheck

/**
 * Extracts the contents of an archive into the specified directory.
 *
 * @param archive an archive file such as a WAR or EAR
 * @param destination a directory to extract the contents to
 * @param filter determines which files get extracted
 * @throws ExtractionException thrown if the archive is not found
 */
public static void extractFilesUsingFilter(File archive, File destination, FilenameFilter filter) throws ExtractionException {
  if (archive == null || destination == null) {
    return;
  }
  try (FileInputStream fis = new FileInputStream(archive)) {
    extractArchive(new ZipArchiveInputStream(new BufferedInputStream(fis)), destination, filter);
  } catch (FileNotFoundException ex) {
    final String msg = String.format("Error extracting file `%s` with filter: %s", archive.getAbsolutePath(), ex.getMessage());
    LOGGER.debug(msg, ex);
    throw new ExtractionException(msg);
  } catch (IOException | ArchiveExtractionException ex) {
    LOGGER.warn("Exception extracting archive '{}'.", archive.getAbsolutePath());
    LOGGER.debug("", ex);
    throw new ExtractionException("Unable to extract from archive", ex);
  }
}

代码示例来源:origin: apache/nifi

@Override
public void process(final InputStream in) throws IOException {
  int fragmentCount = 0;
  try (final ZipArchiveInputStream zipIn = new ZipArchiveInputStream(new BufferedInputStream(in))) {
    ArchiveEntry zipEntry;
    while ((zipEntry = zipIn.getNextEntry()) != null) {

代码示例来源:origin: jeremylong/DependencyCheck

in = new BufferedInputStream(fis);
  ensureReadableJar(archiveExt, in);
  zin = new ZipArchiveInputStream(in);
  extractArchive(zin, destination, engine);
} else if ("tar".equals(archiveExt)) {

代码示例来源:origin: org.apache.commons/commons-compress

return new ZipArchiveInputStream(in, actualEncoding);
return new ZipArchiveInputStream(in);

代码示例来源:origin: plutext/docx4j

public ZipPartStore(InputStream is) throws Docx4JException {
  initMaxBytes();
  
  partByteArrays = new HashMap<String, ByteArray>();
  try {
    ZipArchiveInputStream zis = new ZipArchiveInputStream(is);
    ArchiveEntry entry = null;
    while ((entry = zis.getNextEntry()) != null) {
      // How to read the data descriptor for length? ie before reading?
      byte[] bytes =  getBytesFromInputStream( zis );
      //log.debug("Extracting " + entry.getName());
      policePartSize(null, bytes.length, entry.getName()); 
      partByteArrays.put(entry.getName(), new ByteArray(bytes) );
    }
    zis.close();
  } catch (PartTooLargeException e) {
    throw e;
  } catch (Exception e) {
    throw new Docx4JException("Error processing zip file (is it a zip file?)", e);
  }
}

代码示例来源:origin: pxb1988/dex2jar

@Test
public void test1() throws IOException {
  ZipArchiveInputStream zis = new ZipArchiveInputStream(BadZipEntryFlagTest.class.getResourceAsStream("/bad.zip"));
  for (ZipArchiveEntry e = zis.getNextZipEntry(); e != null; e = zis.getNextZipEntry()) {
    e.getGeneralPurposeBit().useEncryption(false);
    if (!e.isDirectory()) {
      zis.read();
      System.out.println(e.getName());
    }
  }
}

代码示例来源:origin: org.apache.poi/poi-ooxml

Cipher ciEnc = CryptoFunctions.getCipher(skeySpec, CipherAlgorithm.aes128, ChainingMode.cbc, ivBytes, Cipher.ENCRYPT_MODE, PADDING);
ZipArchiveInputStream zis = new ZipArchiveInputStream(is);
FileOutputStream fos = new FileOutputStream(tmpFile);
ZipArchiveOutputStream zos = new ZipArchiveOutputStream(fos);

代码示例来源:origin: apache/tika

private static MediaType tryStreamingDetection(TikaInputStream stream) {
  Set<String> entryNames = new HashSet<>();
  try (InputStream is = new FileInputStream(stream.getFile())) {
    ZipArchiveInputStream zipArchiveInputStream = new ZipArchiveInputStream(is);
    ZipArchiveEntry zae = zipArchiveInputStream.getNextZipEntry();
    while (zae != null) {

代码示例来源:origin: org.apache.ant/ant-compress

/**
 * @param stream the stream to read from, should be buffered
 * @param encoding the encoding of the entry names
 */
@Override
public ArchiveInputStream getArchiveStream(InputStream stream,
                      String encoding)
  throws IOException {
  return new ZipArchiveInputStream(stream, encoding, true);
}

代码示例来源:origin: de.unkrig/de-unkrig-commons

@Override protected ArchiveInputStream
  open(InputStream containerInputStream) {
    return new ZipArchiveInputStream(containerInputStream);
  }
}

代码示例来源:origin: de.unkrig.commons/commons-file

@Override protected ArchiveInputStream
  open(InputStream containerInputStream) {
    return new ZipArchiveInputStream(containerInputStream);
  }
}

代码示例来源:origin: apache/tika

private static void repairCopy(File brokenZip, File fixedZip) {
  try (ZipArchiveOutputStream outputStream = new ZipArchiveOutputStream(fixedZip)) {
    try (InputStream is = new FileInputStream(brokenZip)) {
      ZipArchiveInputStream zipArchiveInputStream = new ZipArchiveInputStream(is);
      ZipArchiveEntry zae = zipArchiveInputStream.getNextZipEntry();
      while (zae != null) {

代码示例来源:origin: apache/tika

public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context)
    throws IOException, SAXException, TikaException {
  ZipArchiveInputStream zip = new ZipArchiveInputStream(stream);
  ZipArchiveEntry entry = zip.getNextZipEntry();

代码示例来源:origin: org.arquillian.spacelift/arquillian-spacelift

@Override
protected ArchiveInputStream compressedInputStream(InputStream compressedFile) {
  BufferedInputStream in = new BufferedInputStream(compressedFile);
  return new ZipArchiveInputStream(in);
}

代码示例来源:origin: org.wso2.carbon/org.wso2.carbon.container

/**
 * Extract zip specified by url to target.
 *
 * @param sourceDistribution url of the archive
 * @param targetDirectory    path of the target
 * @throws IOException
 */
private static void extractZipDistribution(URL sourceDistribution, File targetDirectory) throws IOException {
  extract(new ZipArchiveInputStream(sourceDistribution.openStream()), targetDirectory);
}

代码示例来源:origin: apache/stanbol

public LineIterator getEntries() throws IOException {
  if(name.endsWith(".zip")){
    ZipArchiveInputStream zipIn = new ZipArchiveInputStream(is);
    zipIn.getNextEntry();
    return IOUtils.lineIterator(zipIn, "UTF-8");
  } else {
    return IOUtils.lineIterator(is, "UTF-8");
  }
}

相关文章