/** * Returns the existence of the given entry name * The file name must be relative to the root of the module. * * @param name the file name relative to the root of the module. * @return the existence the given entry name. */ public boolean exists(String name) throws IOException { return getJarEntry(name)!=null; }
/** * Returns the name portion of the archive's URI. * <p> * For JarArhive the name is all of the path that follows * the last slash up to but not including the last dot. * <p> * Here are some example archive names for the specified JarArchive paths: * <ul> * <li>/a/b/c/d.jar -> d * <li>/a/b/c/d -> d * <li>/x/y/z.html -> z * </ul> * @return the name of the archive * */ public String getName() { return JarArchive.getName(getURI()); }
/** * Returns an enumeration of the module file entries with the * specified prefix. All elements in the enumeration are of * type String. Each String represents a file name relative * to the root of the module. * * @param prefix the prefix of entries to be included * @return an enumeration of the archive file entries. */ public Enumeration<String> entries(String prefix) { Enumeration<String> allEntries = entries(); Vector<String> entries = new Vector<String>(); while (allEntries.hasMoreElements()) { String name = allEntries.nextElement(); if (name != null && name.startsWith(prefix)) { entries.add(name); } } return entries.elements(); }
/** * Returns true if the entry is a directory or a plain file * @param name name is one of the entries returned by {@link #entries()} * @return true if the entry denoted by the passed name is a directory */ public boolean isDirectory(String name) { JarEntry entry = getJarEntry(name); if (entry==null) { throw new IllegalArgumentException(name); } return entry.isDirectory(); }