gpt4 book ai didi

org.apache.poi.openxml4j.opc.ZipPackage类的使用及代码示例

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

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

ZipPackage介绍

[英]Physical zip package.
[中]物理拉链包。

代码示例

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

/**
 * Implementation of the getInputStream() which return the inputStream of
 * this part zip entry.
 *
 * @return Input stream of this part zip entry.
 */
@Override
protected InputStream getInputStreamImpl() throws IOException {
  // We use the getInputStream() method from java.util.zip.ZipFile
  // class which return an InputStream to this part zip entry.
  return ((ZipPackage) _container).getZipArchive()
      .getInputStream(zipEntry);
}

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

public void saveImpl(OutputStream outputStream) {
  throwExceptionIfReadOnly();
    if (this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES).size() == 0 &&
      this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES_ECMA376).size() == 0    ) {
      LOG.log(POILogger.DEBUG,"Save core properties part");
      getPackageProperties();
      addPackagePart(this.packageProperties);
    ZipPartMarshaller.marshallRelationshipPart(this.getRelationships(),
        PackagingURIHelper.PACKAGE_RELATIONSHIPS_ROOT_PART_NAME,
        zos);
    for (PackagePart part : getParts()) {

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

/**
 * Retrieve the zip entry of the core properties part.
 *
 * @throws IllegalArgumentException If the relationship for
 *      core properties cannot be read or an invalid name is
 *      specified in the properties.
 */
public static ZipArchiveEntry getCorePropertiesZipEntry(ZipPackage pkg) {
  PackageRelationship corePropsRel = pkg.getRelationshipsByType(
      PackageRelationshipTypes.CORE_PROPERTIES).getRelationship(0);
  if (corePropsRel == null) {
    return null;
  }
  return new ZipArchiveEntry(corePropsRel.getTargetURI().getPath());
}

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

protected void closeImpl() throws IOException {
  flush();
  String tempFileName = generateTempFileName(FileHelper.getDirectory(targetFile)); 
  File tempFile = TempFile.createTempFile(tempFileName, ".tmp");
    save(tempFile);
  } finally {

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

public void saveImpl(OutputStream outputStream) {
  throwExceptionIfReadOnly();
  ZipOutputStream zos = null;
    if (this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES).size() == 0 &&
      this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES_ECMA376).size() == 0    ) {
      logger.log(POILogger.DEBUG,"Save core properties part");
    ZipPartMarshaller.marshallRelationshipPart(this.getRelationships(),
        PackagingURIHelper.PACKAGE_RELATIONSHIPS_ROOT_PART_NAME,
        zos);
    for (PackagePart part : getParts()) {

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

public static OPCPackage create(OutputStream output) {
  OPCPackage pkg = new ZipPackage();
  pkg.originalPackagePath = null;
  pkg.output = output;
  configurePackage(pkg);
  return pkg;
}

代码示例来源:origin: jbaliuka/x4j-analytic

private void marshalUnsavedParts(List<String> savedParts,
    ZipOutputStream out) throws
    OpenXML4JException, IOException {
  for(PackagePart part : pack.getParts() ){
    String entryName = getEntryName(part);
    if (part.isRelationshipPart()){
      continue;
    }
    if(entryName.equals(getEntryName(workBook.getSharedStringSource().getPackagePart()))){					
      continue;
    }
    if (entryName.equals(getEntryName(workBook.getPackagePart()))) {
      continue;
    }
    if(savedParts.contains(entryName)){
      continue;
    }
    if(part instanceof PackageProperties){
      new ZipPackagePropertiesMarshaller().marshall(
          (PackagePart) pack.getPackageProperties(), out);
    }else {
      zipPartMarshaller.marshall(part, out);
    }
    savedParts.add(entryName);
  }
  saveWorkBook(savedParts, workBook, out);
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

try {
      this.contentTypeManager = new ZipContentTypeManager(
          getZipArchive().getInputStream(entry), this);
    } catch (IOException e) {
      throw new InvalidFormatException(e.getMessage());
while (entries.hasMoreElements()) {
  ZipEntry entry = entries.nextElement();
  PackagePartName partName = buildPartName(entry);
  if(partName == null) continue;
while (entries.hasMoreElements()) {
  ZipEntry entry = entries.nextElement();
  PackagePartName partName = buildPartName(entry);
  if(partName == null) continue;

代码示例来源:origin: jbaliuka/x4j-analytic

private void marshalRelationship(ZipOutputStream out) {
  ZipPartMarshaller.marshallRelationshipPart(
      pack.getRelationships(),
      PackagingURIHelper.PACKAGE_RELATIONSHIPS_ROOT_PART_NAME,
      out
  );
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

protected void closeImpl() throws IOException {
  flush();
          generateTempFileName(FileHelper
              .getDirectory(targetFile)), ".tmp");
        save(tempFile);

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

/**
 * Creates a new package.
 *
 * @param file
 *            Path of the document.
 * @return A newly created PackageBase ready to use.
 */
public static OPCPackage create(File file) {
  if (file == null || (file.exists() && file.isDirectory())) {
    throw new IllegalArgumentException("file");
  }
  if (file.exists()) {
    throw new InvalidOperationException(
        "This package (or file) already exists : use the open() method or delete the file.");
  }
  // Creates a new package
  OPCPackage pkg = new ZipPackage();
  pkg.originalPackagePath = file.getAbsolutePath();
  configurePackage(pkg);
  return pkg;
}

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

public void saveImpl(OutputStream outputStream) {
  throwExceptionIfReadOnly();
    if (this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES).size() == 0 &&
      this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES_ECMA376).size() == 0    ) {
      LOG.log(POILogger.DEBUG,"Save core properties part");
      getPackageProperties();
      addPackagePart(this.packageProperties);
    ZipPartMarshaller.marshallRelationshipPart(this.getRelationships(),
        PackagingURIHelper.PACKAGE_RELATIONSHIPS_ROOT_PART_NAME,
        zos);
    for (PackagePart part : getParts()) {

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

in = ((ZipPackage) context.getPackage()).getZipArchive()
      .getInputStream(context.getZipEntry());
} else if (context.getPackage() != null) {
      .getCorePropertiesZipEntry((ZipPackage) context
          .getPackage());
  in = ((ZipPackage) context.getPackage()).getZipArchive()
      .getInputStream(zipEntry);
} else

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

protected void closeImpl() throws IOException {
  flush();
  String tempFileName = generateTempFileName(FileHelper.getDirectory(targetFile)); 
  File tempFile = TempFile.createTempFile(tempFileName, ".tmp");
    save(tempFile);
  } finally {

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

OPCPackage pack = new ZipPackage(file, access);
 try {
   if (pack.partList == null && access != PackageAccess.WRITE) {

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

@Override
protected void buildXHTML(XHTMLContentHandler xhtml) throws SAXException, IOException {
  PackageRelationshipCollection prc = pkg.getRelationshipsByType(XPS_DOCUMENT);
  for (int i = 0; i < prc.size(); i++) {
    PackageRelationship pr = prc.getRelationship(i);
    //there should only be one.
    //in the test file, this points to FixedDocSeq.fdseq
    try {
      handleDocuments(pr, xhtml);
    } catch (TikaException e) {
      throw new SAXException(e);
    }
  }
  //now handle embedded images
  if (embeddedImages.size() > 0) {
    EmbeddedDocumentUtil embeddedDocumentUtil = new EmbeddedDocumentUtil(context);
    for (Map.Entry<String, Metadata> embeddedImage : embeddedImages.entrySet()) {
      String zipPath = embeddedImage.getKey();
      Metadata metadata = embeddedImage.getValue();
        if (embeddedDocumentUtil.shouldParseEmbedded(metadata)) {
          handleEmbeddedImage(
              zipPath,
              metadata,
              embeddedDocumentUtil,
              xhtml);
        }
    }
  }
}

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

private static InputStream getZipStream(String zipPath, ZipPackage zipPackage) throws IOException, TikaException {
    String targPath = (zipPath.length() > 1 && zipPath.startsWith("/") ? zipPath.substring(1) : zipPath);
    ZipEntrySource zipEntrySource = zipPackage.getZipArchive();
    Enumeration<? extends ZipArchiveEntry> zipEntryEnumeration = zipEntrySource.getEntries();
    ZipArchiveEntry zipEntry = null;
    while (zipEntryEnumeration.hasMoreElements()) {
      ZipArchiveEntry ze = zipEntryEnumeration.nextElement();
      if (ze.getName().equals(targPath)) {
        zipEntry = ze;
        break;
      }
    }
    if (zipEntry == null) {
      throw new TikaException("Couldn't find required zip entry: " + zipPath);
    }
    return zipEntrySource.getInputStream(zipEntry);
  }
}

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

OPCPackage pack = new ZipPackage(path, access); // NOSONAR
boolean success = false;
if (pack.partList == null && access != PackageAccess.WRITE) {

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * Retrieve the zip entry of the core properties part.
 *
 * @throws OpenXML4JException
 *             Throws if internal error occurs.
 */
public static ZipEntry getCorePropertiesZipEntry(ZipPackage pkg) {
  PackageRelationship corePropsRel = pkg.getRelationshipsByType(
      PackageRelationshipTypes.CORE_PROPERTIES).getRelationship(0);
  if (corePropsRel == null)
    return null;
  return new ZipEntry(corePropsRel.getTargetURI().getPath());
}

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

/**
 * Implementation of the getInputStream() which return the inputStream of
 * this part zip entry.
 *
 * @return Input stream of this part zip entry.
 */
@Override
protected InputStream getInputStreamImpl() throws IOException {
  // We use the getInputStream() method from java.util.zip.ZipFile
  // class which return an InputStream to this part zip entry.
  return ((ZipPackage) _container).getZipArchive()
      .getInputStream(zipEntry);
}

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