本文整理了Java中org.apache.poi.openxml4j.util.ZipSecureFile.<init>()
方法的一些代码示例,展示了ZipSecureFile.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipSecureFile.<init>()
方法的具体详情如下:
包路径:org.apache.poi.openxml4j.util.ZipSecureFile
类名称:ZipSecureFile
方法名:<init>
暂无
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Opens the specified file as a secure zip, or returns null if no
* such file exists
*
* @param file
* The file to open.
* @return The zip archive freshly open.
* @throws IOException if the zip file cannot be opened or closed to read the header signature
* @throws NotOfficeXmlFileException if stream does not start with zip header signature
*/
public static ZipSecureFile openZipFile(File file) throws IOException, NotOfficeXmlFileException {
if (!file.exists()) {
throw new FileNotFoundException("File does not exist");
}
if (file.isDirectory()) {
throw new IOException("File is a directory");
}
// Peek at the first few bytes to sanity check
try (FileInputStream input = new FileInputStream(file)) {
verifyZipHeader(input);
}
// Open as a proper zip file
return new ZipSecureFile(file);
}
代码示例来源: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.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Opens the specified file as a secure zip, or returns null if no
* such file exists
*
* @param file
* The file to open.
* @return The zip archive freshly open.
* @throws IOException if the zip file cannot be opened or closed to read the header signature
* @throws NotOfficeXmlFileException if stream does not start with zip header signature
*/
public static ZipSecureFile openZipFile(File file) throws IOException, NotOfficeXmlFileException {
if (!file.exists()) {
throw new FileNotFoundException("File does not exist");
}
if (file.isDirectory()) {
throw new IOException("File is a directory");
}
// Peek at the first few bytes to sanity check
try (FileInputStream input = new FileInputStream(file)) {
verifyZipHeader(input);
}
// Open as a proper zip file
return new ZipSecureFile(file);
}
代码示例来源: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!