Examples of ZipEntry


Examples of java.util.zip.ZipEntry

        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

Examples of java.util.zip.ZipEntry

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

Examples of java.util.zip.ZipEntry

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

Examples of java.util.zip.ZipEntry

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

Examples of java.util.zip.ZipEntry

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

Examples of java.util.zip.ZipEntry

   */
  protected void readContentFromZipFile(HttpDoc doc, ZipFile contentZip)
    throws IOException {
    byte[] content = null;
    for (Enumeration enumeration = contentZip.entries(); enumeration.hasMoreElements();) {
      ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();
      if (zipEntry.getName().startsWith("content")) {
        InputStream is = contentZip.getInputStream(zipEntry);
        int length = (int) zipEntry.getSize();
        content = new byte[length];
        int startPos = 0;
        while (startPos < length) {
          startPos += is.read(content, startPos, length - startPos);
        }
View Full Code Here

Examples of java.util.zip.ZipEntry

        new BufferedOutputStream(new FileOutputStream(tempF));
      bos.write(zip);
      bos.close();*/
     
      ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(zip));
      ZipEntry ze;
      final byte[] buff = new byte[1024];
      while ((ze = zis.getNextEntry()) != null) {
//        System.out.println("Cache: inflating " + ze.getName());
        if (ze.isDirectory()) {
          new File(cacheDir, ze.getName()).mkdir();
          continue;
        }
        BufferedOutputStream bo =
          new BufferedOutputStream(new FileOutputStream(new File(cacheDir, ze.getName())));
        while (true) {
          int amountRead = zis.read(buff);
          if (amountRead == -1) {
            break;
          }
View Full Code Here

Examples of java.util.zip.ZipEntry

                }
            }
        } else {
            byte[] buf = new byte[1024];
            int len;
            ZipEntry entry = new ZipEntry(file.getPath());
            FileInputStream fis = new FileInputStream(file);
            BufferedInputStream bis = new BufferedInputStream(fis);
            zos.putNextEntry(entry);
            while ((len = bis.read(buf)) >= 0) {
                zos.write(buf, 0, len);
View Full Code Here

Examples of java.util.zip.ZipEntry

                Enumeration en = zipfile.entries();
                HashMap newRepositories = new HashMap();
                HashMap newResources = new HashMap();

                while (en.hasMoreElements()) {
                    ZipEntry entry = (ZipEntry) en.nextElement();
                    String eName = entry.getName();

                    if (!eName.regionMatches(0, entryPath, 0, entryPath.length())) {
                        // names don't match - not a child of ours
                        continue;
                    }
                    String[] entrypath = StringUtils.split(eName, "/");
                    if (depth > 0 && !shortName.equals(entrypath[depth-1])) {
                        // catch case where our name is Foo and other's is FooBar
                        continue;
                    }

                    // create new repositories and resources for all entries with a
                    // path depth of this.depth + 1
                    if (entrypath.length == depth + 1 && !entry.isDirectory()) {
                        // create a new child resource
                        ZipResource resource = new ZipResource(entry.getName(), this);
                        newResources.put(resource.getShortName(), resource);
                    } else if (entrypath.length > depth) {
                        // create a new child repository
                        if (!newRepositories.containsKey(entrypath[depth])) {
                            ZipEntry child = composeChildEntry(entrypath[depth]);
                            ZipRepository rep = new ZipRepository(file, this, child);
                            newRepositories.put(entrypath[depth], rep);
                        }
                    }
                }
View Full Code Here

Examples of java.util.zip.ZipEntry

        }
    }

    private ZipEntry composeChildEntry(String name) {
        if (entryPath == null || entryPath.length() == 0) {
            return new ZipEntry(name);
        } else if (entryPath.endsWith("/")) {
            return new ZipEntry(entryPath + name);
        } else {
            return new ZipEntry(entryPath + "/" + name);
        }
    }
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.