Examples of ZipFile


Examples of java.util.zip.ZipFile

                /* File is an ordinary file. */
                if (!isArchive(file)) {
                    /* Not a recognized extension; open it to see if
                     it looks like a valid zip file. */
                    try {
                        ZipFile z = new ZipFile(file);
                        z.close();
                        if (warn) {
                            log.warning(Lint.LintCategory.PATH,
                                    "unexpected.archive.file", file);
                        }
                    } catch (IOException e) {
View Full Code Here

Examples of java.util.zip.ZipFile

        }

        Archive archive;
        try {

            ZipFile zdir = null;

            boolean usePreindexedCache = false;
            String preindexCacheLocation = null;

            if (!useOptimizedZip) {
                zdir = new ZipFile(zipFileName);
            } else {
                usePreindexedCache = options.isSet("usezipindex");
                preindexCacheLocation = options.get("java.io.tmpdir");
                String optCacheLoc = options.get("cachezipindexdir");
View Full Code Here

Examples of java.util.zip.ZipFile

    protected ZipFile getZipFile() throws FileSystemException
    {
        if (zipFile == null && this.file.exists())
        {
            ZipFile zipFile = createZipFile(this.file);

            this.zipFile = zipFile;
        }

        return zipFile;
View Full Code Here

Examples of java.util.zip.ZipFile

    protected ZipFile createZipFile(final File file) throws FileSystemException
    {
        try
        {
            return new ZipFile(file);
        }
        catch (IOException ioe)
        {
            throw new FileSystemException("vfs.provider.zip/open-zip-file.error", file, ioe);
        }
View Full Code Here

Examples of java.util.zip.ZipFile

        return retval;
    }

    private static Collection<String> getResourcesFromJarFile(File file, Pattern pattern) {
        ArrayList<String> retval = new ArrayList<String>();
        ZipFile zf;
        try {
            zf = new ZipFile(file);
        } catch (ZipException e) {
            return retval;
        } catch (IOException e) {
            return retval;
        }
        Enumeration e = zf.entries();
        while (e.hasMoreElements()) {
            ZipEntry ze = (ZipEntry) e.nextElement();
            String fileName = ze.getName();
            boolean accept = pattern.matcher(fileName).matches();
            if (accept) {
                retval.add(fileName);
            }
        }
        try {
            zf.close();
        } catch (IOException e1) {
            throw new Error(e1);
        }
        return retval;
    }
View Full Code Here

Examples of java.util.zip.ZipFile

   * @throws RegainException If preparing the document failed.
   */
  public void prepare(RawDocument rawDocument) throws RegainException {
    File file = rawDocument.getContentAsFile();
   
    ZipFile zipFile;
    try {
      zipFile = new ZipFile(file);
    }
    catch (IOException exc) {
      throw new RegainException("Opening OpenOffice file failed: " +
          file.getAbsolutePath(), exc);
    }

    // Read the content.xml
    ZipEntry entry = zipFile.getEntry("content.xml");
    InputStream xmlStream = null;
    String content;
    try {
      xmlStream = zipFile.getInputStream(entry);
      content = RegainToolkit.readStringFromStream(xmlStream, "UTF-8");
    }
    catch (IOException exc) {
      throw new RegainException("Reading text from OpenOffice file failed: " +
          file.getAbsolutePath(), exc);
    }
    finally {
      if (xmlStream != null) {
        try { xmlStream.close(); } catch (IOException exc) {}
      }
      try { zipFile.close(); } catch (IOException exc) {}
    }

    // Clean the content from tags
    String cleanedContent = CrawlerToolkit.cleanFromHtmlTags(content);
    setCleanedContent(cleanedContent);
View Full Code Here

Examples of net.datacrow.util.zip.ZipFile

          }
     
      client.notifyStarted(modules.size());
     
      try {
        ZipFile zf = new ZipFile(new File(parent.getPath(), main.getName().toLowerCase() + "_export.zip"));
     
        for (DcModule module : modules) {
         
          if (canceled) break;
         
          // only export custom modules
          // adds the module jar file to the distribution
          if (module.isCustomModule() && module.getXmlModule() != null) {
              XmlModule xmlModule = module.getXmlModule();
            String jarName = xmlModule.getJarFilename();
            byte[] content = Utilities.readFile(new File(DataCrow.moduleDir, jarName));
            zf.addEntry(jarName, content);
          }

          // settings export
          File file = module.getSettings().getSettings().getSettingsFile();
          module.getSettings().save();
          if (file.exists()) {
              byte[] content = Utilities.readFile(file);
              zf.addEntry(file.getName(), content);
          }
         
          // reports
          if (module.hasReports()) {
              String reportDir = DataCrow.reportDir + module.getName().toLowerCase().replaceAll("[/\\*%., ]", "");
             
                Directory dir = new Directory(reportDir, true, new String[] {"xsl, xslt"});
              for (String filename : dir.read()) {
                  byte[] content = Utilities.readFile(new File(filename));
                  String name = filename.substring(filename.indexOf(File.separator + "reports" + File.separator) + 9);
                        zf.addEntry(name, content);
              }
          }
         
          // item export
          if (!module.isChildModule() &&
                        (((module.getIndex() == parent.getModule() || module instanceof ExternalReferenceModule) && parent.isExportData()) ||
               (!(module instanceof ExternalReferenceModule) && module.getIndex() != parent.getModule() && parent.isExportDataRelatedMods()))) {
         
              try {
                  exportData(module.getIndex());
                 
                  // get the XML
                  file = new File(parent.getPath(), module.getTableName() + ".xml");
                  if (file.exists() && !canceled) {
                      byte[] data = Utilities.readFile(file);
                      zf.addEntry(module.getTableName() + ".xml", data);
                     
                      // get the images
                      File imgPath = new File(parent.getPath(), module.getTableName() + "_images");
                      if (imgPath.exists()) {
                          for (String image : imgPath.list()) {
                             
                              if (canceled) break;
                             
                              // add the image
                              File imgFile = new File(imgPath.toString(), image);
                              byte[] img = Utilities.readFile(imgFile);
                              zf.addEntry(module.getTableName() + "_" + image, img);
                              imgFile.delete();
                          }
                          imgPath.delete();
                      }
                      new File(parent.getPath(), module.getTableName() + ".xsd").delete();
                      file.delete();
                  }
              } catch (Exception e) {
                  client.notifyError(e);
              }
          }
          client.notifyMessage(DcResources.getText("msgExportedModule", module.getLabel()));
          client.notifyProcessed();
        }
       
        zf.close();
      } catch (Exception e) {
        client.notifyError(e);
      }
     
      client.notifyFinished();
View Full Code Here

Examples of net.lingala.zip4j.core.ZipFile

        }
    }

    @Override
    public String guessDocumentIRIFromPackage(File file) throws IOException, ZipException {
        ZipFile zipped = new ZipFile(file);
        if (zipped.isValidZipFile()) {
            File tempDir = Files.createTempDir();
            try {
                LOGGER.info("Extracting: %s to %s", file.getAbsoluteFile(), tempDir.getAbsolutePath());
                zipped.extractAll(tempDir.getAbsolutePath());

                File owlFile = findOwlFile(tempDir);
                return guessDocumentIRIFromFile(owlFile);
            } finally {
                FileUtils.deleteDirectory(tempDir);
View Full Code Here

Examples of net.sf.jazzlib.ZipFile

   * @throws IOException
   */
  @Test
  public void testLoadResources_ZipFile() throws FileNotFoundException, IOException {
    // given
    ZipFile zipFile = new ZipFile(testBookFilename);
   
    // when
    Resources resources = ResourcesLoader.loadResources(zipFile, encoding);
   
    // then
View Full Code Here

Examples of org.apache.commons.compress.archivers.zip.ZipFile

    List<String> fileNames = CollectUtils.newArrayList();
    String dest = destination;
    if (!destination.endsWith(File.separator)) {
      dest = destination + File.separator;
    }
    ZipFile file;
    try {
      file = null;
      if (null == encoding) file = new ZipFile(zipFile);
      else file = new ZipFile(zipFile, encoding);
      @SuppressWarnings("unchecked")
      Enumeration<ZipArchiveEntry> en = file.getEntries();
      ZipArchiveEntry ze = null;
      while (en.hasMoreElements()) {
        ze = en.nextElement();
        File f = new File(dest, ze.getName());
        if (ze.isDirectory()) {
          f.mkdirs();
          continue;
        } else {
          f.getParentFile().mkdirs();
          InputStream is = file.getInputStream(ze);
          OutputStream os = new FileOutputStream(f);
          IOUtils.copy(is, os);
          is.close();
          os.close();
          fileNames.add(f.getAbsolutePath());
        }
      }
      file.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return fileNames;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.