gpt4 book ai didi

org.apache.poi.openxml4j.opc.ZipPackage.openZipEntrySourceStream()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 23:35:31 31 4
gpt4 key购买 nike

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

ZipPackage.openZipEntrySourceStream介绍

暂无

代码示例

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

private static ZipEntrySource openZipEntrySourceStream(File file) throws InvalidOperationException {
  final FileInputStream fis;
  // Acquire a resource that is needed to read the next level of openZipEntrySourceStream
  try {
    // open the file input stream
    fis = new FileInputStream(file); // NOSONAR
  } catch (final FileNotFoundException e) {
    // If the source cannot be acquired, abort (no resources to free at this level)
    throw new InvalidOperationException("Can't open the specified file input stream from file: '" + file + "'", e);
  }
  
  // If an error occurs while reading the next level of openZipEntrySourceStream, free the acquired resource
  try {
    // read from the file input stream
    return openZipEntrySourceStream(fis);
  } catch (final InvalidOperationException|UnsupportedFileFormatException e) {
    // abort: close the zip input stream
    IOUtils.closeQuietly(fis);
    throw e;
  } catch (final Exception e) {
    // abort: close the file input stream
    IOUtils.closeQuietly(fis);
    throw new InvalidOperationException("Failed to read the file input stream from file: '" + file + "'", e);
  }
}

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

/**
 * Constructor. Opens a Zip based Open XML document from a File.
 *
 * @param file
 *            The file to open or create.
 * @param access
 *            The package access mode.
 * @throws InvalidOperationException If the zip file cannot be opened.
 */
ZipPackage(File file, PackageAccess access) throws InvalidOperationException {
  super(access);
  ZipEntrySource ze;
  try {
    final ZipFile zipFile = ZipHelper.openZipFile(file); // NOSONAR
    ze = new ZipFileZipEntrySource(zipFile);
  } catch (IOException e) {
    // probably not happening with write access - not sure how to handle the default read-write access ...
    if (access == PackageAccess.WRITE) {
      throw new InvalidOperationException("Can't open the specified file: '" + file + "'", e);
    }
    if ("java.util.zip.ZipException: archive is not a ZIP archive".equals(e.getMessage())) {
      throw new NotOfficeXmlFileException("archive is not a ZIP archive", e);
    }
    LOG.log(POILogger.ERROR, "Error in zip file "+file+" - falling back to stream processing (i.e. ignoring zip central directory)");
    ze = openZipEntrySourceStream(file);
  }
  this.zipArchive = ze;
}

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

private static ZipEntrySource openZipEntrySourceStream(FileInputStream fis) throws InvalidOperationException {
  final ZipArchiveThresholdInputStream zis;
  // Acquire a resource that is needed to read the next level of openZipEntrySourceStream
  try {
    // open the zip input stream
    zis = ZipHelper.openZipStream(fis); // NOSONAR
  } catch (final IOException e) {
    // If the source cannot be acquired, abort (no resources to free at this level)
    throw new InvalidOperationException("Could not open the file input stream", e);
  }
  
  // If an error occurs while reading the next level of openZipEntrySourceStream, free the acquired resource
  try {
    // read from the zip input stream
    return openZipEntrySourceStream(zis);
  } catch (final InvalidOperationException|UnsupportedFileFormatException e) {
    // abort: close the zip input stream
    IOUtils.closeQuietly(zis);
    throw e;
  } catch (final Exception e) {
    // abort: close the zip input stream
    IOUtils.closeQuietly(zis);
    throw new InvalidOperationException("Failed to read the zip entry source stream", e);
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

private static ZipEntrySource openZipEntrySourceStream(File file) throws InvalidOperationException {
  final FileInputStream fis;
  // Acquire a resource that is needed to read the next level of openZipEntrySourceStream
  try {
    // open the file input stream
    fis = new FileInputStream(file); // NOSONAR
  } catch (final FileNotFoundException e) {
    // If the source cannot be acquired, abort (no resources to free at this level)
    throw new InvalidOperationException("Can't open the specified file input stream from file: '" + file + "'", e);
  }
  
  // If an error occurs while reading the next level of openZipEntrySourceStream, free the acquired resource
  try {
    // read from the file input stream
    return openZipEntrySourceStream(fis);
  } catch (final InvalidOperationException|UnsupportedFileFormatException e) {
    // abort: close the zip input stream
    IOUtils.closeQuietly(fis);
    throw e;
  } catch (final Exception e) {
    // abort: close the file input stream
    IOUtils.closeQuietly(fis);
    throw new InvalidOperationException("Failed to read the file input stream from file: '" + file + "'", e);
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * Constructor. Opens a Zip based Open XML document from a File.
 *
 * @param file
 *            The file to open or create.
 * @param access
 *            The package access mode.
 * @throws InvalidOperationException If the zip file cannot be opened.
 */
ZipPackage(File file, PackageAccess access) throws InvalidOperationException {
  super(access);
  ZipEntrySource ze;
  try {
    final ZipFile zipFile = ZipHelper.openZipFile(file); // NOSONAR
    ze = new ZipFileZipEntrySource(zipFile);
  } catch (IOException e) {
    // probably not happening with write access - not sure how to handle the default read-write access ...
    if (access == PackageAccess.WRITE) {
      throw new InvalidOperationException("Can't open the specified file: '" + file + "'", e);
    }
    if ("java.util.zip.ZipException: archive is not a ZIP archive".equals(e.getMessage())) {
      throw new NotOfficeXmlFileException("archive is not a ZIP archive", e);
    }
    LOG.log(POILogger.ERROR, "Error in zip file "+file+" - falling back to stream processing (i.e. ignoring zip central directory)");
    ze = openZipEntrySourceStream(file);
  }
  this.zipArchive = ze;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

private static ZipEntrySource openZipEntrySourceStream(FileInputStream fis) throws InvalidOperationException {
  final ZipArchiveThresholdInputStream zis;
  // Acquire a resource that is needed to read the next level of openZipEntrySourceStream
  try {
    // open the zip input stream
    zis = ZipHelper.openZipStream(fis); // NOSONAR
  } catch (final IOException e) {
    // If the source cannot be acquired, abort (no resources to free at this level)
    throw new InvalidOperationException("Could not open the file input stream", e);
  }
  
  // If an error occurs while reading the next level of openZipEntrySourceStream, free the acquired resource
  try {
    // read from the zip input stream
    return openZipEntrySourceStream(zis);
  } catch (final InvalidOperationException|UnsupportedFileFormatException e) {
    // abort: close the zip input stream
    IOUtils.closeQuietly(zis);
    throw e;
  } catch (final Exception e) {
    // abort: close the zip input stream
    IOUtils.closeQuietly(zis);
    throw new InvalidOperationException("Failed to read the zip entry source stream", e);
  }
}

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com