Package java.util.zip

Examples of java.util.zip.ZipEntry$LittleEndianReader


        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


        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

    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

    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

   */
  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

        if (iter.hasNext()) {
          comment.append(LF);
        }
      }
    }
    ZipEntry ze = new ZipEntry("header");
    zos.putNextEntry(ze);
    zos.write(comment.toString().getBytes());
    long date = doc.getDateAsMilliSeconds();
    ze.setTime(date > 0 ? date : System.currentTimeMillis());
    zos.closeEntry();
    return ze;
  }
View Full Code Here

   * @param zf
   * @return boolean
   * @throws IOException
   */
  protected boolean readHeadersFromZipFile(HttpDoc doc, ZipFile zf) throws IOException {
    ZipEntry ze = zf.getEntry("header");
    if (ze != null) {
      InputStream is = zf.getInputStream(ze);
      BufferedReader reader = new BufferedReader(new InputStreamReader(is));
      while (reader.ready()) {
        String line = reader.readLine();
View Full Code Here

   * @param zf
   * @return boolean
   * @throws IOException
   */
  protected boolean readLinksFromZipFile(HttpDoc doc, ZipFile zf) throws IOException {
    ZipEntry ze = zf.getEntry("links");
    List links = doc.getLinks();
    if (links == null) {
      links = new Vector();
      doc.setLinks(links);
    } else {
View Full Code Here

   * @return ZipEntry
   * @throws IOException
   */
  protected ZipEntry writeUrlToZipFile(HttpDoc doc, ZipOutputStream zos) throws IOException {
    String url = doc.getURL().toString();
    ZipEntry ze = new ZipEntry("url");
    zos.putNextEntry(ze);
    zos.write(url.getBytes());
    long date = doc.getDateAsMilliSeconds();
    ze.setTime(date > 0 ? date : System.currentTimeMillis());
    zos.closeEntry();
    return ze;
  }
View Full Code Here

   * @param ZipOutputStream
   */ 
  protected void writeLinksToZipFile(List links, ZipOutputStream zs)
    throws IOException {
    HashSet storedLinks = new HashSet();
    ZipEntry zipEntry = new ZipEntry("links");
    zs.putNextEntry(zipEntry);
    for (Iterator iter = links.iterator(); iter.hasNext();) {
      URL url = (URL) iter.next();
      if (!storedLinks.contains(url)) {
        zs.write((url.toString() + LF).getBytes());
View Full Code Here

TOP

Related Classes of java.util.zip.ZipEntry$LittleEndianReader

Copyright © 2018 www.massapicom. 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.