gpt4 book ai didi

com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPlugin.isZipFile()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:35:10 26 4
gpt4 key购买 nike

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

ZipExplorerPlugin.isZipFile介绍

暂无

代码示例

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

/**
 * @param document the document containing the ZIP file as an attachment
 * @param attachmentName the name under which the ZIP file is attached in the document
 * @param context not used
 * @return the list of file entries in the ZIP file attached under the passed attachment name inside the passed
 *         document
 * @see com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPluginAPI#getFileList
 */
public List<String> getFileList(Document document, String attachmentName, XWikiContext context)
{
  List<String> zipList = new ArrayList<String>();
  Attachment attachment = document.getAttachment(attachmentName);
  try {
    byte[] stream = attachment.getContent();
    ByteArrayInputStream bais = new ByteArrayInputStream(stream);
    if (isZipFile(bais)) {
      ZipInputStream zis = new ZipInputStream(bais);
      ZipEntry entry;
      while ((entry = zis.getNextEntry()) != null) {
        zipList.add(entry.getName());
      }
    }
  } catch (XWikiException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return zipList;
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer

/**
 * @param document the document containing the ZIP file as an attachment
 * @param attachmentName the name under which the ZIP file is attached in the document
 * @param context not used
 * @return the list of file entries in the ZIP file attached under the passed attachment name inside the passed
 *         document
 * @see com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPluginAPI#getFileList
 */
public List<String> getFileList(Document document, String attachmentName, XWikiContext context)
{
  List<String> zipList = new ArrayList<String>();
  Attachment attachment = document.getAttachment(attachmentName);
  InputStream stream = null;
  try {
    stream = new ByteArrayInputStream(attachment.getContent());
    if (isZipFile(stream)) {
      ZipInputStream zis = new ZipInputStream(stream);
      ZipEntry entry;
      while ((entry = zis.getNextEntry()) != null) {
        zipList.add(entry.getName());
      }
    }
  } catch (XWikiException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return zipList;
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

if (!isZipFile(attachment.getContentInputStream(context))) {
  return attachment;

代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer

stream = new BufferedInputStream(attachment.getContentInputStream(context));
if (!isZipFile(stream)) {
  return attachment;

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