gpt4 book ai didi

de.tudarmstadt.ukp.clarin.webanno.support.ZipUtils类的使用及代码示例

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

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

ZipUtils介绍

[英]A utility class.
[中]实用课。

代码示例

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-project

/**
 * copy project log files from the exported project
 * @param zip the ZIP file.
 * @param aProject the project.
 * @throws IOException if an I/O error occurs.
 */
@SuppressWarnings("rawtypes")
@Deprecated
private void createProjectLog(ZipFile zip, Project aProject)
  throws IOException
{
  for (Enumeration zipEnumerate = zip.entries(); zipEnumerate.hasMoreElements();) {
    ZipEntry entry = (ZipEntry) zipEnumerate.nextElement();
    // Strip leading "/" that we had in ZIP files prior to 2.0.8 (bug #985)
    String entryName = ZipUtils.normalizeEntryName(entry);
    
    if (entryName.startsWith(LOG_FOLDER + "/")) {
      FileUtils.copyInputStreamToFile(zip.getInputStream(entry),
          getProjectLogFile(aProject));
      log.info("Imported log for project [" + aProject.getName() + "] with id ["
          + aProject.getId() + "]");
    }
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-api-dao

ZipUtils.zipFolder(exportTempDir, projectZipFile);

代码示例来源:origin: webanno/webanno

private static void addToZip(ZipOutputStream zip, File aBasePath, File aPath)
  throws IOException
{
  if (aPath.isDirectory()) {
    for (File file : aPath.listFiles()) {
      addToZip(zip, aBasePath, file);
    }
  }
  else {
    FileInputStream in = null;
    try {
      in = new FileInputStream(aPath);
      String relativePath = aBasePath.toURI().relativize(aPath.toURI()).getPath();
      zip.putNextEntry(new ZipEntry(relativePath));
      IOUtils.copy(in, zip);
    }
    finally {
      closeQuietly(in);
    }
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-remote

OutputStream os = new FileOutputStream(tempFile);
) {
  if (!ZipUtils.isZipStream(is)) {
    throw new UnsupportedFormatException("Invalid ZIP file");

代码示例来源:origin: webanno/webanno

OutputStream os = new FileOutputStream(tempFile);
) {
  if (!ZipUtils.isZipStream(is)) {
    throw new UnsupportedFormatException("Invalid ZIP file");

代码示例来源:origin: webanno/webanno

/**
 * copy Project META_INF from the exported project
 * @param zip the ZIP file.
 * @param aProject the project.
 * @throws IOException if an I/O error occurs.
 */
@Deprecated
@SuppressWarnings("rawtypes")
private void createProjectMetaInf(ZipFile zip, Project aProject)
  throws IOException
{
  for (Enumeration zipEnumerate = zip.entries(); zipEnumerate.hasMoreElements();) {
    ZipEntry entry = (ZipEntry) zipEnumerate.nextElement();
    // Strip leading "/" that we had in ZIP files prior to 2.0.8 (bug #985)
    String entryName = ZipUtils.normalizeEntryName(entry);
    if (entryName.startsWith(META_INF_FOLDER + "/")) {
      File metaInfDir = new File(getMetaInfFolder(aProject),
          FilenameUtils.getPath(entry.getName().replace(META_INF_FOLDER + "/", "")));
      // where the file reside in the META-INF/... directory
      FileUtils.forceMkdir(metaInfDir);
      FileUtils.copyInputStreamToFile(zip.getInputStream(entry), new File(metaInfDir,
          FilenameUtils.getName(entry.getName())));
      
      log.info("Imported META-INF for project [" + aProject.getName() + "] with id ["
          + aProject.getId() + "]");
    }
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.app/inception-ui-core

OutputStream os = new FileOutputStream(tempFile);
) {
  if (!ZipUtils.isZipStream(is)) {
    throw new IOException("Invalid ZIP file");

代码示例来源:origin: webanno/webanno

ZipUtils.zipFolder(exportTempDir, projectZipFile);

代码示例来源:origin: webanno/webanno

/**
 * While exporting annotation documents, some of the writers generate multiple outputs, e.g. a
 * type system file in addition to the annotation data. This method generates a zip file if the
 * exported file do contain multiple file output
 * 
 * @param srcFolder source folder.
 * @param destZipFile target folder.
 * @throws IOException if an I/O error occurs.
 */
public static void zipFolder(File srcFolder, File destZipFile)
  throws IOException
{
  ZipOutputStream zip = null;
  try {
    zip = new ZipOutputStream(new FileOutputStream(destZipFile));
    for (File file : srcFolder.getAbsoluteFile().listFiles()) {
      addToZip(zip, srcFolder.getAbsoluteFile(), file);
    }
    zip.flush();
  }
  finally {
    closeQuietly(zip);
  }
}

代码示例来源:origin: webanno/webanno

/**
 * copy project log files from the exported project
 * @param zip the ZIP file.
 * @param aProject the project.
 * @throws IOException if an I/O error occurs.
 */
@SuppressWarnings("rawtypes")
@Deprecated
private void createProjectLog(ZipFile zip, Project aProject)
  throws IOException
{
  for (Enumeration zipEnumerate = zip.entries(); zipEnumerate.hasMoreElements();) {
    ZipEntry entry = (ZipEntry) zipEnumerate.nextElement();
    // Strip leading "/" that we had in ZIP files prior to 2.0.8 (bug #985)
    String entryName = ZipUtils.normalizeEntryName(entry);
    
    if (entryName.startsWith(LOG_FOLDER + "/")) {
      FileUtils.copyInputStreamToFile(zip.getInputStream(entry),
          getProjectLogFile(aProject));
      log.info("Imported log for project [" + aProject.getName() + "] with id ["
          + aProject.getId() + "]");
    }
  }
}

代码示例来源:origin: inception-project/inception

OutputStream os = new FileOutputStream(tempFile);
) {
  if (!ZipUtils.isZipStream(is)) {
    throw new IOException("Invalid ZIP file");

代码示例来源:origin: webanno/webanno

ExportUtil.exportCuratedDocuments(documentService, importExportService,
    ProjectExportForm.this.getModelObject(), exportTempDir, false);
ZipUtils.zipFolder(exportTempDir, new File(
    exportTempDir.getAbsolutePath() + ".zip"));
exportFile = new File(exportTempDir.getAbsolutePath()

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-project

String entryName = ZipUtils.normalizeEntryName(entry);

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-ui-project

OutputStream os = new FileOutputStream(tempFile);
) {
  if (!ZipUtils.isZipStream(is)) {
    throw new IOException("Invalid ZIP file");

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-ui-project

ExportUtil.exportCuratedDocuments(documentService, importExportService,
    ProjectExportForm.this.getModelObject(), exportTempDir, false);
ZipUtils.zipFolder(exportTempDir, new File(
    exportTempDir.getAbsolutePath() + ".zip"));
exportFile = new File(exportTempDir.getAbsolutePath()

代码示例来源:origin: webanno/webanno

String entryName = ZipUtils.normalizeEntryName(entry);

代码示例来源:origin: webanno/webanno

OutputStream os = new FileOutputStream(tempFile);
) {
  if (!ZipUtils.isZipStream(is)) {
    throw new IOException("Invalid ZIP file");

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-api-dao

exportFile = new File(exportTempDir.getAbsolutePath() + ".zip");
try {
  ZipUtils.zipFolder(exportTempDir, exportFile);

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-project

/**
 * copy Project META_INF from the exported project
 * @param zip the ZIP file.
 * @param aProject the project.
 * @throws IOException if an I/O error occurs.
 */
@Deprecated
@SuppressWarnings("rawtypes")
private void createProjectMetaInf(ZipFile zip, Project aProject)
  throws IOException
{
  for (Enumeration zipEnumerate = zip.entries(); zipEnumerate.hasMoreElements();) {
    ZipEntry entry = (ZipEntry) zipEnumerate.nextElement();
    // Strip leading "/" that we had in ZIP files prior to 2.0.8 (bug #985)
    String entryName = ZipUtils.normalizeEntryName(entry);
    if (entryName.startsWith(META_INF_FOLDER + "/")) {
      File metaInfDir = new File(getMetaInfFolder(aProject),
          FilenameUtils.getPath(entry.getName().replace(META_INF_FOLDER + "/", "")));
      // where the file reside in the META-INF/... directory
      FileUtils.forceMkdir(metaInfDir);
      FileUtils.copyInputStreamToFile(zip.getInputStream(entry), new File(metaInfDir,
          FilenameUtils.getName(entry.getName())));
      
      log.info("Imported META-INF for project [" + aProject.getName() + "] with id ["
          + aProject.getId() + "]");
    }
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-remote

if (!ZipUtils.isZipStream(is)) {
  return ResponseEntity.badRequest().body("Invalid ZIP file");

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