本文整理了Java中org.apache.poi.openxml4j.util.ZipFileZipEntrySource
类的一些代码示例,展示了ZipFileZipEntrySource
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipFileZipEntrySource
类的具体详情如下:
包路径:org.apache.poi.openxml4j.util.ZipFileZipEntrySource
类名称:ZipFileZipEntrySource
[英]A ZipEntrySource wrapper around a ZipFile. Should be as low in terms of memory as a normal ZipFile implementation is.
[中]围绕ZipFile的ZipEntrySource包装器。内存应该和普通ZipFile实现一样低。
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Write out this workbook to an OutputStream.
*
* @param stream - the java OutputStream you wish to write to
* @exception IOException if anything can't be written.
*/
@Override
public void write(OutputStream stream) throws IOException {
flushSheets();
//Save the template
File tmplFile = TempFile.createTempFile("poi-sxssf-template", ".xlsx");
boolean deleted;
try {
try (FileOutputStream os = new FileOutputStream(tmplFile)) {
_wb.write(os);
}
//Substitute the template entries with the generated sheet data files
try (ZipSecureFile zf = new ZipSecureFile(tmplFile);
ZipFileZipEntrySource source = new ZipFileZipEntrySource(zf)) {
injectData(source, stream);
}
} finally {
deleted = tmplFile.delete();
}
if(!deleted) {
throw new IOException("Could not delete temporary file after processing: " + tmplFile);
}
}
代码示例来源: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: apache/tika
zipEntrySource = new ZipFileZipEntrySource(new ZipFile(stream.getFile()));
} catch (IOException e) {
return tryStreamingDetection(stream);
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* Constructor. Opens a Zip based Open XML document.
*
* @param path
* The path of the file to open or create.
* @param access
* The package access mode.
* @throws InvalidFormatException
* If the content type part parsing encounters an error.
*/
ZipPackage(String path, PackageAccess access) {
super(access);
ZipFile zipFile = ZipHelper.openZipFile(path);
if (zipFile == null)
throw new InvalidOperationException(
"Can't open the specified file: '" + path + "'");
this.zipArchive = new ZipFileZipEntrySource(zipFile);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Write out this workbook to an OutputStream.
*
* @param stream - the java OutputStream you wish to write to
* @exception IOException if anything can't be written.
*/
@Override
public void write(OutputStream stream) throws IOException {
flushSheets();
//Save the template
File tmplFile = TempFile.createTempFile("poi-sxssf-template", ".xlsx");
boolean deleted;
try {
try (FileOutputStream os = new FileOutputStream(tmplFile)) {
_wb.write(os);
}
//Substitute the template entries with the generated sheet data files
try (ZipSecureFile zf = new ZipSecureFile(tmplFile);
ZipFileZipEntrySource source = new ZipFileZipEntrySource(zf)) {
injectData(source, stream);
}
} finally {
deleted = tmplFile.delete();
}
if(!deleted) {
throw new IOException("Could not delete temporary file after processing: " + tmplFile);
}
}
代码示例来源: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.tika/tika-parsers
zipEntrySource = new ZipFileZipEntrySource(new ZipFile(stream.getFile()));
} catch (IOException e) {
return null;
内容来源于网络,如有侵权,请联系作者删除!