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


Java ZipEntry.getName方法代码示例

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


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

示例1: getEntryList

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
public static List<String> getEntryList(File file) throws IOException {
    List<String> result = new ArrayList<String>();

    ZipFile archiveZip = new ZipFile(file);
    boolean oldFormat = isOldFormat(archiveZip);
    Enumeration<?> list = archiveZip.entries();
    while (list.hasMoreElements()) {
        ZipEntry entry = (ZipEntry) list.nextElement();
        String name = entry.getName();
        if (oldFormat && name.endsWith(".pdu")) {
            name = name.replace(".pdu", "");
            result.add(name);
        } else if (!oldFormat && name.endsWith("/")) {
            int first = name.indexOf('/');
            int last = name.lastIndexOf('/');
            if (first == last) {
                name = name.replace("/", "");
                result.add(name);
            }
        }
    }
    return result;
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:24,代码来源:SimulationUtil.java

示例2: getABIsFromApk

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
private static Set<String> getABIsFromApk(String apk) {
	try {
		ZipFile apkFile = new ZipFile(apk);
		Enumeration<? extends ZipEntry> entries = apkFile.entries();
		Set<String> supportedABIs = new HashSet<String>();
		while (entries.hasMoreElements()) {
			ZipEntry entry = entries.nextElement();
			String name = entry.getName();
			if (name.contains("../")) {
				continue;
			}
			if (name.startsWith("lib/") && !entry.isDirectory() && name.endsWith(".so")) {
				String supportedAbi = name.substring(name.indexOf("/") + 1, name.lastIndexOf("/"));
				supportedABIs.add(supportedAbi);
			}
		}
		return supportedABIs;
	} catch (Exception e) {
		e.printStackTrace();
	}

	return null;
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:24,代码来源:NativeLibraryHelperCompat.java

示例3: searchJarForClasses

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
/**
 * Get the class file entries from the Jar
 */
static String[] searchJarForClasses(URL jar)
        throws IOException {
    Vector v = new Vector();
    InputStream in = jar.openStream();
    ZipInputStream zin = new ZipInputStream(in);

    ZipEntry ze;
    while ((ze = zin.getNextEntry()) != null) {
        String name = ze.getName();
        if (isClassFileName(name))
            v.addElement(canonicalizeClassName(name));
    }
    zin.close();

    String[] sa = new String[v.size()];
    v.copyInto(sa);
    return sa;
}
 
开发者ID:imkiva,项目名称:Krine,代码行数:22,代码来源:KrineClassPath.java

示例4: extractProjectFiles

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
private ArrayList<String> extractProjectFiles(ZipFile inputZip, File projectRoot)
    throws IOException {
  ArrayList<String> projectFileNames = Lists.newArrayList();
  Enumeration<? extends ZipEntry> inputZipEnumeration = inputZip.entries();
  while (inputZipEnumeration.hasMoreElements()) {
    ZipEntry zipEntry = inputZipEnumeration.nextElement();
    final InputStream extractedInputStream = inputZip.getInputStream(zipEntry);
    File extractedFile = new File(projectRoot, zipEntry.getName());
    LOG.info("extracting " + extractedFile.getAbsolutePath() + " from input zip");
    Files.createParentDirs(extractedFile); // Do I need this?
    Files.copy(
        new InputSupplier<InputStream>() {
          public InputStream getInput() throws IOException {
            return extractedInputStream;
          }
        },
        extractedFile);
    projectFileNames.add(extractedFile.getPath());
  }
  return projectFileNames;
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:22,代码来源:ProjectBuilder.java

示例5: addZipEntry

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
@Override
void addZipEntry(ZipEntry entry) {
    String name = entry.getName();
    if (!name.startsWith(prefix.path)) {
        return;
    }
    name = name.substring(prefix.path.length());
    int i = name.lastIndexOf('/');
    RelativeDirectory dirname = new RelativeDirectory(name.substring(0, i+1));
    String basename = name.substring(i + 1);
    if (basename.length() == 0) {
        return;
    }
    List<String> list = map.get(dirname);
    if (list == null)
        list = List.nil();
    list = list.prepend(basename);
    map.put(dirname, list);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:20,代码来源:SymbolArchive.java

示例6: unpackZipFile

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
/**
 * Unpacks a ZIP file to disk.
 * All entries are unpacked, even {@code META-INF/MANIFEST.MF} if present.
 * Parent directories are created as needed (even if not mentioned in the ZIP);
 * empty ZIP directories are created too.
 * Existing files are overwritten.
 * @param zip a ZIP file
 * @param dir the base directory in which to unpack (need not yet exist)
 * @throws IOException in case of problems
 */
public static void unpackZipFile(File zip, File dir) throws IOException {
    byte[] buf = new byte[8192];
    InputStream is = new FileInputStream(zip);
    try {
        ZipInputStream zis = new ZipInputStream(is);
        ZipEntry entry;
        while ((entry = zis.getNextEntry()) != null) {
            String name = entry.getName();
            int slash = name.lastIndexOf('/');
            File d = new File(dir, name.substring(0, slash).replace('/', File.separatorChar));
            if (!d.isDirectory() && !d.mkdirs()) {
                throw new IOException("could not make " + d);
            }
            if (slash != name.length() - 1) {
                File f = new File(dir, name.replace('/', File.separatorChar));
                OutputStream os = new FileOutputStream(f);
                try {
                    int read;
                    while ((read = zis.read(buf)) != -1) {
                        os.write(buf, 0, read);
                    }
                } finally {
                    os.close();
                }
            }
        }
    } finally {
        is.close();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:TestFileUtils.java

示例7: writeZip

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
/**
 * Copies the content of a Jar/Zip archive into the receiver archive.
 * <p/>An optional {@link IZipEntryFilter} allows to selectively choose which files
 * to copy over.
 *
 * @param input  the {@link InputStream} for the Jar/Zip to copy.
 * @param filter the filter or <code>null</code>
 * @throws IOException
 */
public void writeZip(InputStream input, IZipEntryFilter filter)
        throws IOException, IZipEntryFilter.ZipAbortException {
    ZipInputStream zis = new ZipInputStream(input);
    try {
        // loop on the entries of the intermediary package and put them in the final package.
        ZipEntry entry;
        while ((entry = zis.getNextEntry()) != null) {
            String name = entry.getName();
            // do not take directories or anything inside a potential META-INF folder.
            if (entry.isDirectory() || name.startsWith("META-INF/")) {
                continue;
            }
            // if we have a filter, we check the entry against it
            if (filter != null && filter.checkEntry(name) == false) {
                continue;
            }
            JarEntry newEntry;
            // Preserve the STORED method of the input entry.
            if (entry.getMethod() == JarEntry.STORED) {
                newEntry = new JarEntry(entry);
            } else {
                // Create a new entry so that the compressed len is recomputed.
                newEntry = new JarEntry(name);
            }
            writeEntry(zis, newEntry);
            zis.closeEntry();
        }
    } finally {
        zis.close();
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:41,代码来源:SignedJarBuilder.java

示例8: listZipElements

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
public static LinkedList<String> listZipElements(File file, boolean recursive, final boolean subzipasdir) throws Exception {
	final LinkedList<String> o=new LinkedList<String>();
	// ZipInputStream zipfile = new ZipInputStream(file);
	// ZipEntry e;
	// while ((e=zipfile.getNextEntry())!=null) {
	ZipFile zipfile=new ZipFile(file);
	Enumeration<? extends ZipEntry> en=zipfile.entries();

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

		final String f=e.getName();

		if(f.endsWith(".zip")&&recursive){
			File tempfile=new File(FileUtils._TEMP_DIR+"FileUtils_zipListTemp"+(Math.random()*Float.MAX_VALUE)+".tmp");
			FileOutputStream bout=new FileOutputStream(tempfile);
			try{
				StreamUtils.inputStreamToOutputStream(zipfile.getInputStream(e),bout);
			}catch(Exception exc){}
			bout.close();
			LinkedList<String> o2=listZipElements(tempfile,true);
			FileUtils.delete(tempfile);
			for(String o2s:o2){
				if(subzipasdir) o.add(f+"/"+o2s);
				else o.add(o2s);
			}
		}else o.add(f);
	}
	zipfile.close();
	return o;
}
 
开发者ID:riccardobl,项目名称:DDSWriter,代码行数:32,代码来源:FileUtils.java

示例9: getEntries

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
@Override
List<JournalEntry> getEntries() {
    try {
        List<JournalEntry> result = new ArrayList<JournalEntry>();
        for (ZipEntry zipEntry : getZipEntries()) {
            String entryName = zipEntry.getName();
            if (JournalEntry.isCommittedJournalName(entryName)) {
                result.add(new JournalEntry.ZipJournalEntry(zipFile_, zipEntry));
            }
        }
        return result;
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:16,代码来源:FullJournalEntries.java

示例10: readJarClasses

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
private Set<String> readJarClasses(Path jar) throws IOException {
  Set<String> result = new HashSet<>();
  try (ZipInputStream in = new ZipInputStream(new FileInputStream(jar.toFile()))) {
    ZipEntry entry = in.getNextEntry();
    while (entry != null) {
      String name = entry.getName();
      if (name.endsWith(".class")) {
        result.add(name.substring(0, name.length() - ".class".length()).replace('/', '.'));
      }
      entry = in.getNextEntry();
    }
  }
  return result;
}
 
开发者ID:inferjay,项目名称:r8,代码行数:15,代码来源:IncludeDescriptorClassesTest.java

示例11: unzipData

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
private String unzipData(InputStream is, String extension,
        File writeDirectory) throws IOException {

    String baseFileName = UUID.randomUUID().toString();

    ZipInputStream zipInputStream = new ZipInputStream(is);
    ZipEntry entry;

    String returnFile = null;

    while ((entry = zipInputStream.getNextEntry()) != null) {

        String currentExtension = entry.getName();
        int beginIndex = currentExtension.lastIndexOf(".") + 1;
        currentExtension = currentExtension.substring(beginIndex);

        String fileName = baseFileName + "." + currentExtension;
        File currentFile = new File(writeDirectory, fileName);
        if (!writeDirectory.exists()) {
            writeDirectory.mkdir();
        }
        currentFile.createNewFile();
        FileOutputStream fos = new FileOutputStream(currentFile);

        org.apache.commons.io.IOUtils.copy(zipInputStream, fos);

        if (currentExtension.equalsIgnoreCase(extension)) {
            returnFile = currentFile.getAbsolutePath();
        }

        fos.close();
    }
    zipInputStream.close();
    return returnFile;
}
 
开发者ID:52North,项目名称:javaps-geotools-backend,代码行数:36,代码来源:GenericFileDataWithGT.java

示例12: getName

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
private String getName(final ZipEntry ze) {
    String name = ze.getName();
    if (isClassEntry(ze)) {
        if (inRepresentation != BYTECODE && outRepresentation == BYTECODE) {
            name = name.substring(0, name.length() - 4); // .class.xml to
            // .class
        } else if (inRepresentation == BYTECODE
                && outRepresentation != BYTECODE) {
            name += ".xml"; // .class to .class.xml
        }
        // } else if( CODE2ASM.equals( command)) {
        // name = name.substring( 0, name.length()-6).concat( ".asm");
    }
    return name;
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:16,代码来源:Processor.java

示例13: createConfig

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
/**
 * Creates a configuration from an entry in the given resource.
 */
public JSLibSingleTestConfig createConfig(ZipEntry entry, String resourceName) {
	final String entryName = entry.getName();
	final String modifier = (blacklist.contains(entryName)) ? JSLibSingleTestConfig.BLACKLIST : null;
	return new JSLibSingleTestConfig(entry, resourceName, modifier);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:9,代码来源:JSLibSingleTestConfigProvider.java

示例14: unpack

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
public static void unpack(File zipfile) {
    try {
        ZipFile zip = new ZipFile(zipfile);
        ZipEntry info = zip.getEntry("__PROJECT_INFO__");
        BufferedReader in = new BufferedReader(new InputStreamReader(zip.getInputStream(info), "UTF-8"));
        String pId = in.readLine();
        String pType = in.readLine();
        String pTitle = in.readLine();
        String pStartD = in.readLine();
        String pEndD = in.readLine();
        in.close();
        if (ProjectManager.getProject(pId) != null) {
            int n =
                JOptionPane.showConfirmDialog(
                    App.getFrame(),
                    Local.getString("This project is already exists and will be replaced.\nContinue?"),
                    Local.getString("Project is already exists"),
                    JOptionPane.YES_NO_OPTION);
            if (n != JOptionPane.YES_OPTION) {
                zip.close();
                return;
            }	
            ProjectManager.removeProject(pId);
        }
        Project prj = ProjectManager.createProject(pId, Project.Type.valueOf(pType), pTitle, new CalendarDate(pStartD), null);
        if (pEndD != null)
            prj.setEndDate(new CalendarDate(pEndD));
        //File prDir = new File(JN_DOCPATH + prj.getID());
        Enumeration files;           
        for (files = zip.entries(); files.hasMoreElements();){
            ZipEntry ze = (ZipEntry)files.nextElement();
            if ( ze.isDirectory() )
            {
               File theDirectory = new File (JN_DOCPATH + prj.getID()+ "/" + ze.getName() );
               // create this directory (including any necessary parent directories)
               theDirectory.mkdirs();
               theDirectory = null;
            }
            if ((!ze.getName().equals("__PROJECT_INFO__")) && (!ze.isDirectory())) {
                FileOutputStream out = new FileOutputStream(JN_DOCPATH + prj.getID() +"/"+ ze.getName());
                InputStream inp = zip.getInputStream(ze);
                
                byte[] buffer = new byte[1024];
                int len;

                while((len = inp.read(buffer)) >= 0)
                  out.write(buffer, 0, len);

                inp.close();
                out.close();
                
            }
        }
        zip.close();
        CurrentStorage.get().storeProjectManager();             
    }
    catch (Exception ex) {
        new ExceptionDialog(ex, "Failed to read from "+zipfile, "Make sure that this file is a Memoranda project archive.");
    }
}
 
开发者ID:ser316asu,项目名称:Reinickendorf_SER316,代码行数:61,代码来源:ProjectPackager.java

示例15: isClassEntry

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
private boolean isClassEntry(final ZipEntry ze) {
    String name = ze.getName();
    return inRepresentation == SINGLE_XML && name.equals(SINGLE_XML_NAME)
            || name.endsWith(".class") || name.endsWith(".class.xml");
}
 
开发者ID:acmerli,项目名称:fastAOP,代码行数:6,代码来源:Processor.java


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