本文整理了Java中org.apache.poi.openxml4j.util.ZipEntrySource
类的一些代码示例,展示了ZipEntrySource
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipEntrySource
类的具体详情如下:
包路径:org.apache.poi.openxml4j.util.ZipEntrySource
类名称:ZipEntrySource
[英]An Interface to make getting the different bits of a Zip File easy. Allows you to get at the ZipEntries, without needing to worry about ZipFile vs ZipInputStream being annoyingly very different.
[中]一个接口,可以轻松获取Zip文件的不同部分。让你可以使用ZipPentries,而不必担心ZipFile和ZipInputStream会有很大的不同。
代码示例来源:origin: org.apache.poi/poi-ooxml
protected void injectData(ZipEntrySource zipEntrySource, OutputStream out) throws IOException {
ZipArchiveOutputStream zos = new ZipArchiveOutputStream(out);
try {
Enumeration<? extends ZipArchiveEntry> en = zipEntrySource.getEntries();
while (en.hasMoreElements()) {
ZipArchiveEntry ze = en.nextElement();
zeOut.setTime(ze.getTime());
zos.putArchiveEntry(zeOut);
try (final InputStream is = zipEntrySource.getInputStream(ze)) {
if (is instanceof ZipArchiveThresholdInputStream) {
zipEntrySource.close();
代码示例来源:origin: org.apache.poi/poi-ooxml
zipArchive.getEntry(CONTENT_TYPES_PART_NAME);
if (contentTypeEntry != null) {
if (this.contentTypeManager != null) {
zipArchive.getInputStream(contentTypeEntry), this);
} catch (IOException e) {
throw new InvalidFormatException(e.getMessage(), e);
final boolean hasMimetype = zipArchive.getEntry(MIMETYPE) != null;
final boolean hasSettingsXML = zipArchive.getEntry(SETTINGS_XML) != null;
if (hasMimetype && hasSettingsXML) {
throw new ODFNotOfficeXmlFileException(
"Formats like these (eg ODS, ODP) are not supported, try Apache ODFToolkit");
if (!zipArchive.getEntries().hasMoreElements()) {
throw new NotOfficeXmlFileException(
"No valid entries or contents found, this is not a valid OOXML " +
Collections.list(zipArchive.getEntries()).stream()
.map(zae -> new EntryTriple(zae, contentTypeManager))
.filter(mm -> mm.partName != null)
代码示例来源: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
/**
* Close the package without saving the document. Discard all the changes
* made to this package.
*/
@Override
protected void revertImpl() {
try {
if (this.zipArchive != null) {
this.zipArchive.close();
}
} catch (IOException e) {
// Do nothing, user dont have to know
}
}
代码示例来源: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.openl.rules/org.openl.lib.poi.dev
/**
* Retrieve the Zip entry of the content types part.
*/
public static ZipEntry getContentTypeZipEntry(ZipPackage pkg) {
Enumeration entries = pkg.getZipArchive().getEntries();
// Enumerate through the Zip entries until we find the one named
// '[Content_Types].xml'.
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) entries.nextElement();
if (entry.getName().equals(
ContentTypeManager.CONTENT_TYPES_PART_NAME))
return entry;
}
return null;
}
代码示例来源:origin: org.apache.tika/tika-parsers
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: apache/tika
private static void closeQuietly(ZipEntrySource zipEntrySource) {
if (zipEntrySource == null) {
return;
}
try {
zipEntrySource.close();
} catch (IOException e) {
//swallow
}
}
/**
代码示例来源:origin: org.apache.poi/poi-ooxml
if (context.getZipEntry() != null) {
in = ((ZipPackage) context.getPackage()).getZipArchive()
.getInputStream(context.getZipEntry());
} else if (context.getPackage() != null) {
.getPackage());
in = ((ZipPackage) context.getPackage()).getZipArchive()
.getInputStream(zipEntry);
} else
throw new IOException(
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
protected void injectData(ZipEntrySource zipEntrySource, OutputStream out) throws IOException {
ZipArchiveOutputStream zos = new ZipArchiveOutputStream(out);
try {
Enumeration<? extends ZipArchiveEntry> en = zipEntrySource.getEntries();
while (en.hasMoreElements()) {
ZipArchiveEntry ze = en.nextElement();
zeOut.setTime(ze.getTime());
zos.putArchiveEntry(zeOut);
try (final InputStream is = zipEntrySource.getInputStream(ze)) {
if (is instanceof ZipArchiveThresholdInputStream) {
zipEntrySource.close();
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
zipArchive.getEntry(CONTENT_TYPES_PART_NAME);
if (contentTypeEntry != null) {
if (this.contentTypeManager != null) {
zipArchive.getInputStream(contentTypeEntry), this);
} catch (IOException e) {
throw new InvalidFormatException(e.getMessage(), e);
final boolean hasMimetype = zipArchive.getEntry(MIMETYPE) != null;
final boolean hasSettingsXML = zipArchive.getEntry(SETTINGS_XML) != null;
if (hasMimetype && hasSettingsXML) {
throw new ODFNotOfficeXmlFileException(
"Formats like these (eg ODS, ODP) are not supported, try Apache ODFToolkit");
if (!zipArchive.getEntries().hasMoreElements()) {
throw new NotOfficeXmlFileException(
"No valid entries or contents found, this is not a valid OOXML " +
Collections.list(zipArchive.getEntries()).stream()
.map(zae -> new EntryTriple(zae, contentTypeManager))
.filter(mm -> mm.partName != null)
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
Enumeration<? extends ZipEntry> entries = this.zipArchive.getEntries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
try {
this.contentTypeManager = new ZipContentTypeManager(
getZipArchive().getInputStream(entry), this);
} catch (IOException e) {
throw new InvalidFormatException(e.getMessage());
entries = this.zipArchive.getEntries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
entries = this.zipArchive.getEntries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
代码示例来源:origin: org.apache.tika/tika-parsers
private static void closeQuietly(ZipEntrySource zipEntrySource) {
if (zipEntrySource == null) {
return;
}
try {
zipEntrySource.close();
} catch (IOException e) {
//swallow
}
}
/**
代码示例来源: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);
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* Close the package without saving the document. Discard all the changes
* made to this package.
*/
@Override
protected void revertImpl() {
try {
if (this.zipArchive != null)
this.zipArchive.close();
} catch (IOException e) {
// Do nothing, user dont have to know
}
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* 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.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Close the package without saving the document. Discard all the changes
* made to this package.
*/
@Override
protected void revertImpl() {
try {
if (this.zipArchive != null) {
this.zipArchive.close();
}
} catch (IOException e) {
// Do nothing, user dont have to know
}
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
if (context.getZipEntry() != null) {
in = ((ZipPackage) context.getPackage()).getZipArchive()
.getInputStream(context.getZipEntry());
} else if (context.getPackage() != null) {
.getPackage());
in = ((ZipPackage) context.getPackage()).getZipArchive()
.getInputStream(zipEntry);
} else
throw new IOException(
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
this.zipArchive.close();
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
if (context.getZipEntry() != null) {
in = ((ZipPackage) context.getPackage()).getZipArchive()
.getInputStream(context.getZipEntry());
} else if (context.getPackage() != null) {
.getPackage());
in = ((ZipPackage) context.getPackage()).getZipArchive()
.getInputStream(zipEntry);
} else
throw new IOException(
内容来源于网络,如有侵权,请联系作者删除!