Examples of ZipEntry


Examples of com.alimama.mdrill.utils.zip.ZipEntry

        BufferedInputStream bis;
        byte[] cache = new byte[CACHE_SIZE];
        for (FileStatus file : files) {
            if (file.isDir()) {
                pathName = file.getPath().toString().substring(basePath.toString().length() + 1) + "/";
                zos.putNextEntry(new ZipEntry(pathName));
                zipFile(fs,file, basePath, zos);
            } else {
                pathName = file.getPath().toString().substring(basePath.toString().length() + 1);
                is = fs.open(file.getPath());
                bis = new BufferedInputStream(is);
                zos.putNextEntry(new ZipEntry(pathName));
                int nRead = 0;
                while ((nRead = bis.read(cache, 0, CACHE_SIZE)) != -1) {
                    zos.write(cache, 0, nRead);
                }
                bis.close();
View Full Code Here

Examples of de.schlichtherle.truezip.zip.ZipEntry

        Enumeration<? extends ZipEntry> en = getZipFile().entries();

        while ( en.hasMoreElements() )
        {
            final ZipEntry e = en.nextElement();

            final String name = e.getName();

            if ( filter != null && !filter.accepts( name ) )
            {
                continue;
            }
View Full Code Here

Examples of de.schlichtherle.util.zip.ZipEntry

        } else {
            Pattern pattern = Pattern.compile(".*\\.mc[ra]$");
            // World pattern
            Pattern worldPattern = Pattern.compile(worldName + "\\$");
            for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
                ZipEntry testEntry = e.nextElement();
                // Check for world
                if (worldPattern.matcher(worldName).matches()) {
                    // Check for file
                    if (pattern.matcher(testEntry.getName()).matches()) {
                        folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/"));
                        name = folder + "/" + name;
                        break;
                    }
                }
            }

            // Check if world is found
            if (folder == null) {
                throw new MissingWorldException("Target world is not present in ZIP.", worldName);
            }
        }

        ZipEntry entry = getEntry(name);
        if (entry == null) {
            throw new MissingChunkException();
        }
        try {
            return zip.getInputStream(entry);
View Full Code Here

Examples of flex2.compiler.swc.zip.ZipEntry

            for (Iterator<VirtualFile> it = files.values().iterator(); it.hasNext(); )
            {
                VirtualFile f = it.next();

                ZipEntry entry = new ZipEntry( f.getName() );
                entry.setTime(f.getLastModified());
                zos.putNextEntry( entry );

                BufferedInputStream in = new BufferedInputStream(f.getInputStream());
                FileUtil.streamOutput(in, zos);
                zos.closeEntry();
View Full Code Here

Examples of gnu.zip.ZipEntry

    public final void close() throws IOException {
        zip.close();
    }

    public final ArchiveEntry getEntry(final String name) {
        ZipEntry entry = zip.getEntry(name);

        if (entry == null) {
            return null;
        }
View Full Code Here

Examples of java.util.zip.ZipEntry

        if (f.isDirectory()) {
            if (!filePath.endsWith("/")) {
                filePath += '/';
            }
            if (!dir.getPath().startsWith(filePath.substring(0,filePath.length()-1))) {
                ZipEntry entry = new ZipEntry(filePath);
                l.add(entry);
            }

            for (File subFile : f.listFiles()) {
                addEntriesRecursive(l, subFile, dirPath);
            }
        } else {
            ZipEntry entry = new ZipEntry(filePath);
            l.add(entry);
            entry.setSize(f.length());
        }
    }
View Full Code Here

Examples of java.util.zip.ZipEntry

        File[] files = dir.listFiles();
        for (int k = 0; k < files.length; k++) {
          File file = files[k];
          if (file.isFile()) {
            InputStream in = new FileInputStream(file);
            ZipEntry ze =
              new ZipEntry(
                "resources/"
                  + bean.getId()
                  + "/"
                  + file.getName());
            zip.putNextEntry(ze);

            // Transfer bytes from the file to the ZIP file
            int len;
            while ((len = in.read(buf)) > 0) {
              zip.write(buf, 0, len);
            }

            zip.closeEntry();
            in.close();
          }
        }
      }

      // add images
      File root =
        new File(getServletContext().getRealPath("/"), imagesPath);
      File[] files = root.listFiles();
      for (int k = 0; k < files.length; k++) {
        File file = files[k];
        if (file.isFile()) {
          InputStream in = new FileInputStream(file);
          ZipEntry ze = new ZipEntry("images/" + file.getName());
          zip.putNextEntry(ze);

          // Transfer bytes from the file to the ZIP file
          int len;
          while ((len = in.read(buf)) > 0) {
            zip.write(buf, 0, len);
          }

          zip.closeEntry();
          in.close();
        }
      }

      // add sections
      Mapping.begin();
      Vector sections = Section.listAll();
      Mapping.rollback();
      for (int i = 0; i < sections.size(); i++) {
        Section section = (Section) sections.get(i);
        try {
          URL url =
            new URL(
              frontUrl+"/section/"
                + section.getId()
                + ".html?static=true&nocache=true");
          BufferedReader reader =
            new BufferedReader(
              new InputStreamReader(url.openStream()));
          String content = "<!-- �ON static export -->";
          String line = "";
          while (line != null) {
            line = reader.readLine();
            if (line != null) {
              content += line;
            }
          }

          ZipEntry ze =
            new ZipEntry("section/" + section.getId() + ".html");
          zip.putNextEntry(ze);
          zip.write(content.getBytes());
          zip.closeEntry();
        } catch (Exception e) {
          System.out.println(
            "Static export error, section " + section.getId());
        }
      }

      // add publications
      Mapping.begin();
      Vector publications = Publication.listAll();
      Mapping.rollback();
      for (int i = 0; i < publications.size(); i++) {
        Publication publication = (Publication) publications.get(i);
        try {
          URL url =
            new URL(
              frontUrl+"/publication/"
                + publication.getId()
                + ".html?static=true&nocache=true");
          BufferedReader reader =
            new BufferedReader(
              new InputStreamReader(url.openStream()));
          String content = "<!-- �ON static export -->";
          String line = "";
          while (line != null) {
            line = reader.readLine();
            if (line != null) {
              content += line;
            }
          }
          ZipEntry ze =
            new ZipEntry(
              "publication/" + publication.getId() + ".html");
          zip.putNextEntry(ze);
          zip.write(content.getBytes());
          zip.closeEntry();
        } catch (Exception e) {
          System.out.println(
            "Static export error, publication "
              + publication.getId());
        }
      }

      // add index
      URL url =
        new URL(
          frontUrl+"?static=true&nocache=true");
      BufferedReader reader =
        new BufferedReader(new InputStreamReader(url.openStream()));
      String content = "<!-- �ON static export -->";
      String line = "";
      while (line != null) {
        line = reader.readLine();
        if (line != null) {
          content += line;
        }
      }
      ZipEntry ze = new ZipEntry("section/index.html");
      zip.putNextEntry(ze);
      zip.write(content.getBytes());
      zip.closeEntry();
      ze = new ZipEntry("index.html");
      zip.putNextEntry(ze);
      String redirect =
        "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=section/index.html\">";
      zip.write(redirect.getBytes());
      zip.closeEntry();
View Full Code Here

Examples of java.util.zip.ZipEntry

    for (String entry : files) {
      File f = new File(dir, entry);
      if (f.isDirectory()) {
        addDirectory(f, zos, parentLength);
      } else {
        ZipEntry e = new ZipEntry(f.getPath().substring(parentLength));
        zos.putNextEntry(e);
        FileUtils.write(f, zos);
        zos.closeEntry();
      }
    }
View Full Code Here

Examples of java.util.zip.ZipEntry

    Enumeration zipFileEntries = zipFile.entries();

    // Process each entry
    while (zipFileEntries.hasMoreElements()) {
      // grab a zip file entry
      ZipEntry entry = (ZipEntry) zipFileEntries.nextElement();

      String currentEntry = entry.getName();

      File destFile = new File(unzipDestinationDirectory, currentEntry);

      // grab file's parent directory structure
      File destinationParent = destFile.getParentFile();

      // create the parent directory structure if needed
      destinationParent.mkdirs();

      // extract file if not a directory
      if (!entry.isDirectory()) {
        ObjectConverterUtil.write(zipFile.getInputStream(entry),
            destFile);
      }
    }
    zipFile.close();
View Full Code Here

Examples of java.util.zip.ZipEntry

   */
  protected void writeContentToZipFile(HttpDoc doc, ZipOutputStream zos)
    throws IOException {
    String contenttype = doc.getHeaderValue(HttpHeader.CONTENT_TYPE);
    String extension = getExtensionFromContenttype(contenttype);
    ZipEntry zipEntry = new ZipEntry("content" + extension);
    long date = doc.getLastModifiedAsMilliSeconds();
    if (date < 0) {
      date = doc.getDateAsMilliSeconds();
    }
    zipEntry.setTime(date);
    zos.putNextEntry(zipEntry);
    zos.write(doc.getContent());
    zos.closeEntry();
  }
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.