gpt4 book ai didi

org.apache.poi.openxml4j.util.ZipSecureFile.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 04:05:31 38 4
gpt4 key购买 nike

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

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);
  }
}

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