Examples of ZipArchiveEntry


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

            zf = new ZipFile(srcF, getEncoding(), true);
            boolean empty = true;
            Enumeration e = zf.getEntries();
            while (e.hasMoreElements()) {
                empty = false;
                ZipArchiveEntry ze = (ZipArchiveEntry) e.nextElement();
                if (getSkipUnreadableEntries() && !zf.canReadEntryData(ze)) {
                    log(Messages.skippedIsUnreadable(ze));
                    continue;
                }
                log("extracting " + ze.getName(), Project.MSG_DEBUG);
                InputStream is = null;
                try {
                    extractFile(fileUtils, srcF, dir,
                                is = zf.getInputStream(ze),
                                ze.getName(), new Date(ze.getTime()),
                                ze.isDirectory(), mapper);
                } finally {
                    FileUtils.close(is);
                }
            }
            if (empty && getFailOnEmptyArchive()) {
View Full Code Here

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

            });
        setEntryBuilder(
              new ArchiveBase.EntryBuilder() {
                public ArchiveEntry buildEntry(ArchiveBase.ResourceWithFlags r) {
                    boolean isDir = r.getResource().isDirectory();
                    ZipArchiveEntry ent = new ZipArchiveEntry(r.getName());
                    ent.setTime(round(r.getResource().getLastModified(), 2000));
                    ent.setSize(isDir ? 0 : r.getResource().getSize());

                    if (!isDir && r.getCollectionFlags().hasModeBeenSet()) {
                        ent.setUnixMode(r.getCollectionFlags().getMode());
                    } else if (isDir
                               && r.getCollectionFlags().hasDirModeBeenSet()) {
                        ent.setUnixMode(r.getCollectionFlags().getDirMode());
                    } else if (r.getResourceFlags().hasModeBeenSet()) {
                        ent.setUnixMode(r.getResourceFlags().getMode());
                    } else {
                        ent.setUnixMode(isDir
                                        ? ArchiveFileSet.DEFAULT_DIR_MODE
                                        : ArchiveFileSet.DEFAULT_FILE_MODE);
                    }

                    if (r.getResourceFlags().getZipExtraFields() != null) {
                        ent.setExtraFields(r.getResourceFlags()
                                           .getZipExtraFields());
                    }
                    if (keepCompression
                        && r.getResourceFlags().hasCompressionMethod()) {
                        ent.setMethod(r.getResourceFlags()
                                      .getCompressionMethod());
                    }

                    return ent;
                }
View Full Code Here

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

                                      matchDirEntries);
            return;
        }

        File srcFile = fp.getFile();
        ZipArchiveEntry entry = null;
        ZipFile zf = null;

        try {
            try {
                zf = new ZipFile(srcFile, encoding);
            } catch (ZipException ex) {
                throw new BuildException("Problem reading " + srcFile, ex);
            } catch (IOException ex) {
                throw new BuildException("Problem opening " + srcFile, ex);
            }
            Enumeration e = zf.getEntries();
            while (e.hasMoreElements()) {
                entry = (ZipArchiveEntry) e.nextElement();
                if (getSkipUnreadableEntries() && !zf.canReadEntryData(entry)) {
                    log(Messages.skippedIsUnreadable(entry));
                    continue;
                }
                Resource r = new ZipResource(srcFile, encoding, entry);
                String name = entry.getName();
                if (entry.isDirectory()) {
                    name = trimSeparator(name);
                    dirEntries.put(name, r);
                    if (match(name)) {
                        matchDirEntries.put(name, r);
                    }
View Full Code Here

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

    final List<File> unzippedFiles = new LinkedList<File>();
    final InputStream is = new FileInputStream(inputFile);
    final ZipArchiveInputStream debInputStream = (ZipArchiveInputStream) new ArchiveStreamFactory()
        .createArchiveInputStream("zip", is);
    ZipArchiveEntry entry = null;
    while ((entry = (ZipArchiveEntry) debInputStream.getNextEntry()) != null) {
      final File outputFile = new File(outputDir, entry.getName());
      if (entry.isDirectory()) {
        LOG.info(String.format(
            "Attempting to write output directory %s.", outputFile
                .getAbsolutePath()));
        if (!outputFile.exists()) {
          LOG.info(String.format(
View Full Code Here

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

        }
        else{

            String name = file.getName();
            if(!name.startsWith(".")){
                ZipArchiveEntry entry = (ZipArchiveEntry) out.createArchiveEntry(file,
                    path + name);
                out.putArchiveEntry(entry);
                byte[] buf = new byte[1024];
                int len;
                FileInputStream in = new FileInputStream(file);
View Full Code Here

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

   * @param zipFile the zip file from which to extract the manifest
   * @return a String representing the manifest contents
   * @throws IOException
   */
  public static String extractManifest(ZipFile zipFile) throws IOException{
    ZipArchiveEntry entry = zipFile.getEntry(IW3CXMLConfiguration.MANIFEST_FILE);
    return IOUtils.toString(zipFile.getInputStream(entry), "UTF-8");
  }
View Full Code Here

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

   * @return the input stream
   * @throws ZipException
   * @throws IOException
   */
  public static InputStream getEntryStream(String entry, ZipFile zipFile) throws ZipException, IOException{
    ZipArchiveEntry zipEntry;
    zipEntry = zipFile.getEntry(entry);
    if (zipEntry == null) return null;
    return zipFile.getInputStream(zipEntry);
  }
View Full Code Here

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

    if (targetFolder.exists() && targetFolder.isDirectory()) FileUtils.deleteDirectory(targetFolder);
   
    targetFolder.mkdirs();
    BufferedOutputStream out = null;
    InputStream in = null;
    ZipArchiveEntry zipEntry;

    Enumeration entries = zipfile.getEntries();
    try {
      while (entries.hasMoreElements()){
        zipEntry = (ZipArchiveEntry)entries.nextElement();
        // Don't add directories - use mkdirs instead
        if(!zipEntry.isDirectory()) {
          File outFile = new File(targetFolder, zipEntry.getName());

          // Ensure that the parent Folder exists
          if(!outFile.getParentFile().exists()) {
            outFile.getParentFile().mkdirs();
          }
          // Read the entry
          in = new BufferedInputStream(zipfile.getInputStream(zipEntry));
          out = new BufferedOutputStream(new FileOutputStream(outFile));
          IOUtils.copy(in, out);
          // Restore time stamp
          outFile.setLastModified(zipEntry.getTime());
         
          // Close File
          out.close();
          // Close Stream
          in.close();
View Full Code Here

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

            path = path + file.getName() +"/";
            for(File afile: file.listFiles()){
                pack(afile,out, path);
            }
        } else {
          ZipArchiveEntry entry = (ZipArchiveEntry) out.createArchiveEntry(file, path + file.getName());
        out.putArchiveEntry(entry);
            byte[] buf = new byte[1024];
            int len;
            FileInputStream in = new FileInputStream(file);
            while ((len = in.read(buf)) > 0) {
View Full Code Here

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

            }
            if(zipArchive != null){
                boolean isError = false;
                Enumeration<ZipArchiveEntry> entries = zipArchive.getEntries();
                while(entries.hasMoreElements()){
                    ZipArchiveEntry entry = entries.nextElement();
                    if(!entry.isDirectory()){
                        String entryName = entry.getName();
                        log.info("     o loading entry '{}'", entryName);
                        try {
                            ResourceState state = resourceImporter.importResource(
                                zipArchive.getInputStream(entry),
                                FilenameUtils.getName(entryName));
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.