当前位置: 首页>>代码示例>>Java>>正文


Java ZipArchiveEntry.getName方法代码示例

本文整理汇总了Java中org.apache.commons.compress.archivers.zip.ZipArchiveEntry.getName方法的典型用法代码示例。如果您正苦于以下问题:Java ZipArchiveEntry.getName方法的具体用法?Java ZipArchiveEntry.getName怎么用?Java ZipArchiveEntry.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.compress.archivers.zip.ZipArchiveEntry的用法示例。


在下文中一共展示了ZipArchiveEntry.getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractZip

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
private void extractZip(ZipFile zipFile) {
  Enumeration<ZipArchiveEntry> entries = zipFile.getEntries();
  while (entries.hasMoreElements()) {

    ZipArchiveEntry entry = entries.nextElement();
    String fileName = entry.getName();
    File outputFile = new File(config.getExtractionFolder(), fileName);

    if (entry.isDirectory()) {
      makeDirectory(outputFile);
    } else {
      createNewFile(outputFile);
      try {
        InputStream inputStream = zipFile.getInputStream(entry);
        extractFile(inputStream, outputFile, fileName);
      } catch (IOException e) {
        throw new ExtractionException("Error extracting file '" + fileName + "' "
            + "from downloaded file: " + config.getDownloadTarget(), e);
      }
    }
  }
}
 
开发者ID:AlejandroRivera,项目名称:embedded-rabbitmq,代码行数:23,代码来源:BasicExtractor.java

示例2: makeOnlyUnZip

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
public static void makeOnlyUnZip() throws ArchiveException, IOException{
		final InputStream is = new FileInputStream("D:/中文名字.zip");
		ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.ZIP, is);
		ZipArchiveEntry entry = entry = (ZipArchiveEntry) in.getNextEntry();
		
		String dir = "D:/cnname";
		File filedir = new File(dir);
		if(!filedir.exists()){
			filedir.mkdir();
		}
//		OutputStream out = new FileOutputStream(new File(dir, entry.getName()));
		OutputStream out = new FileOutputStream(new File(filedir, entry.getName()));
		IOUtils.copy(in, out);
		out.close();
		in.close();
	}
 
开发者ID:h819,项目名称:spring-boot,代码行数:17,代码来源:CompressExample.java

示例3: getStroomZipNameSet

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
public StroomZipNameSet getStroomZipNameSet() throws IOException {
	if (stroomZipNameSet == null) {
		stroomZipNameSet = new StroomZipNameSet(false);
		Enumeration<ZipArchiveEntry> entryE = getZipFile().getEntries();

		while (entryE.hasMoreElements()) {
			ZipArchiveEntry entry = entryE.nextElement();

			// Skip Dir's
			if (!entry.isDirectory()) {
				String fileName = entry.getName();
				stroomZipNameSet.add(fileName);
			}

			long entrySize = entry.getSize();
			if (entrySize == -1 || totalSize == -1) {
				// Can nolonger sum
			} else {
				totalSize += entrySize;
			}

		}

	}
	return stroomZipNameSet;
}
 
开发者ID:gchq,项目名称:stroom-agent,代码行数:27,代码来源:StroomZipFile.java

示例4: getStroomZipNameSet

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
public StroomZipNameSet getStroomZipNameSet() throws IOException {
    if (stroomZipNameSet == null) {
        stroomZipNameSet = new StroomZipNameSet(false);
        Enumeration<ZipArchiveEntry> entryE = getZipFile().getEntries();

        while (entryE.hasMoreElements()) {
            ZipArchiveEntry entry = entryE.nextElement();

            // Skip Dir's
            if (!entry.isDirectory()) {
                String fileName = entry.getName();
                stroomZipNameSet.add(fileName);
            }

            long entrySize = entry.getSize();
            if (entrySize > 0) {
                totalSize += entrySize;
            }

        }
    }
    return stroomZipNameSet;
}
 
开发者ID:gchq,项目名称:stroom-proxy,代码行数:24,代码来源:StroomZipFile.java

示例5: extract

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
private static void extract(ZipArchiveEntry zipArchiveEntry, ZipFile zipFile, File outputDir) throws IOException {
    File extractedFile = new File(outputDir, zipArchiveEntry.getName());
    FileUtils.forceMkdir(extractedFile.getParentFile());
    if (zipArchiveEntry.isUnixSymlink()) {
        if (PosixUtil.isPosixFileStore(outputDir)) {
            logger.debug("Extracting [l] "+zipArchiveEntry.getName());
            String symlinkTarget = zipFile.getUnixSymlink(zipArchiveEntry);
            Files.createSymbolicLink(extractedFile.toPath(), new File(symlinkTarget).toPath());
        } else {
            logger.debug("Skipping ! [l] "+zipArchiveEntry.getName());
        }
    } else if (zipArchiveEntry.isDirectory()) {
        logger.debug("Extracting [d] "+zipArchiveEntry.getName());
        FileUtils.forceMkdir(extractedFile);
    } else {
        logger.debug("Extracting [f] "+zipArchiveEntry.getName());
        try (
                InputStream in = zipFile.getInputStream(zipArchiveEntry);
                OutputStream out = new FileOutputStream(extractedFile)
        ) {
            IOUtils.copy(in, out);
        }
    }
    updatePermissions(extractedFile, zipArchiveEntry.getUnixMode());
}
 
开发者ID:ctco,项目名称:gradle-mobile-plugin,代码行数:26,代码来源:ZipUtil.java

示例6: extractZipFile

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
private static void extractZipFile(final File destination, final ZipFile zipFile) throws IOException {
    final Enumeration<ZipArchiveEntry> entries = zipFile.getEntries();

    while (entries.hasMoreElements()) {
        final ZipArchiveEntry entry = entries.nextElement();
        final File entryDestination = new File(destination, entry.getName());

        if (entry.isDirectory()) {
            entryDestination.mkdirs();
        } else {
            entryDestination.getParentFile().mkdirs();
            final InputStream in = zipFile.getInputStream(entry);
            try (final OutputStream out = new FileOutputStream(entryDestination)) {
                IOUtils.copy(in, out);
                IOUtils.closeQuietly(in);
            }
        }
    }
}
 
开发者ID:awslabs,项目名称:aws-codepipeline-plugin-for-jenkins,代码行数:20,代码来源:ExtractionTools.java

示例7: detectKmz

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
private static MediaType detectKmz(ZipFile zip) {
    boolean kmlFound = false;

    Enumeration<ZipArchiveEntry> entries = zip.getEntries();
    while (entries.hasMoreElements()) {
        ZipArchiveEntry entry = entries.nextElement();
        String name = entry.getName();
        if (!entry.isDirectory()
                && name.indexOf('/') == -1 && name.indexOf('\\') == -1) {
            if (name.endsWith(".kml") && !kmlFound) {
                kmlFound = true;
            } else {
                return null;
            }
        }
    }

    if (kmlFound) {
        return MediaType.application("vnd.google-earth.kmz");
    } else {
        return null;
    }
}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:24,代码来源:ZipContainerDetector.java

示例8: detectIpa

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static MediaType detectIpa(ZipFile zip) {
    // Note - consider generalising this logic, if another format needs many regexp matching
    Set<Pattern> tmpPatterns = (Set<Pattern>)ipaEntryPatterns.clone();
    
    Enumeration<ZipArchiveEntry> entries = zip.getEntries();
    while (entries.hasMoreElements()) {
        ZipArchiveEntry entry = entries.nextElement();
        String name = entry.getName();
        
        Iterator<Pattern> ip = tmpPatterns.iterator();
        while (ip.hasNext()) {
            if (ip.next().matcher(name).matches()) {
                ip.remove();
            }
        }
        if (tmpPatterns.isEmpty()) {
            // We've found everything we need to find
            return MediaType.application("x-itunes-ipa");
        }
    }
    
    // If we get here, not all required entries were found
    return null;
}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:26,代码来源:ZipContainerDetector.java

示例9: extractEntireZip

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
@SuppressWarnings("ResultOfMethodCallIgnored")
public static void extractEntireZip(@NotNull final File zip, @NotNull final File restoreDir) throws IOException {
    try (ZipFile zipFile = new ZipFile(zip)) {
        final Enumeration<ZipArchiveEntry> zipEntries = zipFile.getEntries();
        while (zipEntries.hasMoreElements()) {
            final ZipArchiveEntry zipEntry = zipEntries.nextElement();
            final File entryFile = new File(restoreDir, zipEntry.getName());
            if (zipEntry.isDirectory()) {
                entryFile.mkdirs();
            } else {
                entryFile.getParentFile().mkdirs();
                try (FileOutputStream target = new FileOutputStream(entryFile)) {
                    try (InputStream in = zipFile.getInputStream(zipEntry)) {
                        IOUtil.copyStreams(in, target, IOUtil.BUFFER_ALLOCATOR);
                    }
                }
            }
        }
    }
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:21,代码来源:BackupTests.java

示例10: extractZipEntry

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
/**
 * Private Helper Method to Perform Extract of Compressed File with the Zip.
 *
 * @param zipFile
 * @param entry
 * @param outputDirectory
 * @throws java.io.IOException
 */
private static void extractZipEntry(ZipFile zipFile, ZipArchiveEntry entry, File outputDirectory)
        throws IOException {

    BufferedInputStream content = new BufferedInputStream(zipFile.getInputStream(entry), 16384);
    FileOutputStream fileOutputStream = new FileOutputStream(new File(outputDirectory + File.separator + entry.getName()));
    try {
        final byte[] buffer = new byte[16384];
        int n = 0;
        while (-1 != (n = content.read(buffer))) {
            fileOutputStream.write(buffer, 0, n);
        }

    } finally {
        content.close();
        fileOutputStream.flush();
        fileOutputStream.close();
    }
}
 
开发者ID:jaschenk,项目名称:jeffaschenk-commons,代码行数:27,代码来源:ArchiveUtility.java

示例11: unzip

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
private void unzip(File file, String dest) throws IOException {
	try (ZipFile zip = new ZipFile(file)) {
		Enumeration<? extends ZipArchiveEntry> entries = zip.getEntries();
		while (entries.hasMoreElements()) {
			ZipArchiveEntry entry = entries.nextElement();
			File entryDestination = new File(dest, entry.getName());
			if (entry.isDirectory()) {
				entryDestination.mkdirs();
			} else {
				if (!entryDestination.getParentFile().exists()) {
					entryDestination.getParentFile().mkdirs();
				}
				try (InputStream in = zip.getInputStream(entry);
					OutputStream out = new FileOutputStream(entryDestination)) {
					IOUtils.copy(in, out);
				}
			}
		}
	}
}
 
开发者ID:openmrs,项目名称:openmrs-module-owa,代码行数:21,代码来源:DefaultAppManager.java

示例12: getConfiguration

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
public Configuration getConfiguration(InputStreamDataSource configStream) throws IOException {
    Configuration configuration = new Configuration(false);
    try (ZipArchiveInputStream zipInputStream = new ZipArchiveInputStream(configStream.getInputStream())) {
        ZipArchiveEntry zipEntry = zipInputStream.getNextZipEntry();
        while (zipEntry != null) {
            String name = zipEntry.getName();
            if ( name.endsWith("core-site.xml") || name.endsWith("hdfs-site.xml") ) {
                if ( verbose ) System.err.println("Reading \"" + name + "\" into Configuration.");
                ByteArrayOutputStream boas = new ByteArrayOutputStream();
                IOUtils.copy(zipInputStream, boas);
                configuration.addResource(new ByteArrayInputStream(boas.toByteArray()), name);
            }
            zipEntry = zipInputStream.getNextZipEntry();
        }
    }
    return configuration;
}
 
开发者ID:ezbake,项目名称:ezbakehelpers-cdh-config-exporter,代码行数:18,代码来源:Cdh2EzProperties.java

示例13: unpackZipFile

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
/**
 * Unpacks a ZIP file to the destination directory.
 *
 * @throws MojoExecutionException
 *           if something goes wrong during unpacking the files.
 */
public void unpackZipFile(final File file, final File destinationDirectory,
    final String... exclusions) {

  Set<String> exclusionSet = new HashSet<>(Arrays.asList(exclusions));

  try (ZipFile zipFile = new ZipFile(file)) {
    Enumeration<? extends ZipArchiveEntry> entries = zipFile.getEntries();
    while (entries.hasMoreElements()) {
      ZipArchiveEntry entry = entries.nextElement();
      String name = entry.getName();

      if (!exclusionSet.contains(name)) {
        File destFile = new File(destinationDirectory, entry.getName());
        unpackEntry(destFile, zipFile, entry);
      }
    }
  } catch (IOException e) {
    throw new UncheckedIOException("Could not uncompress distribution package file "
        + file.getAbsolutePath() + " to target folder " + destinationDirectory.getAbsolutePath(),
        e);
  }
}
 
开发者ID:everit-org,项目名称:eosgi-maven-plugin,代码行数:29,代码来源:FileManager.java

示例14: next

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
public InputStream next() {
    ZipArchiveEntry zipEntry = zipEntries.nextElement();

    StopWatch sw = new StopWatch(zipEntry.getName());

    InputStream feStream = null;

    try {
        return zipFile.getInputStream(zipEntry);
    } catch (IOException e) {
        IOUtils.closeQuietly(feStream);

        return null;
    } finally {
        IOUtils.closeQuietly(feStream);

        System.out.print(sw.prettyPrint());
    }
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:20,代码来源:ZipFileIterator.java

示例15: unzip

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
public static void unzip(File zipFile, File destination)
        throws IOException {
    ZipFile zip = new ZipFile(zipFile);
    try {
        Enumeration<ZipArchiveEntry> e = zip.getEntries();
        while (e.hasMoreElements()) {
            ZipArchiveEntry entry = e.nextElement();
            File file = new File(destination, entry.getName());
            if (entry.isDirectory()) {
                file.mkdirs();
            } else {
                InputStream is = zip.getInputStream(entry);
                File parent = file.getParentFile();
                if (parent != null && parent.exists() == false) {
                    parent.mkdirs();
                }
                FileOutputStream os = new FileOutputStream(file);
                try {
                    IOUtils.copy(is, os);
                } finally {
                    os.close();
                    is.close();
                }
                file.setLastModified(entry.getTime());
                int mode = entry.getUnixMode();
                if ((mode & EXEC_MASK) != 0) {
                    if (!file.setExecutable(true)) {
                    }
                }
            }
        }
    } finally {
        ZipFile.closeQuietly(zip);
    }
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:36,代码来源:MavenDownloader.java


注:本文中的org.apache.commons.compress.archivers.zip.ZipArchiveEntry.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。