Package com.iizix.util
Interface IJarFile
- All Superinterfaces:
- java.lang.AutoCloseable,- java.io.Closeable
 - All Known Implementing Classes:
- MemoryJarFile,- XJarFile
 - public interface IJarFile extends java.io.CloseableMethods to get the URL from the Jar or memory Jar file, its stream handler and the byte array data of an Zip (Jar) entry.- Author:
- Christopher Mindus
 
- Method Summary- All Methods Instance Methods Abstract Methods Default Methods - Modifier and Type - Method - Description - void- close()Closes the Jar file.- java.util.Enumeration<java.util.jar.JarEntry>- entries()Returns an enumeration of the Jar file entries.- java.util.zip.ZipEntry- getEntry(java.lang.String name)Returns the zip file entry for the specified name, or null if not found.- byte[]- getEntryData(java.lang.String name)Gets the byte [] data for an entry if present.- byte[]- getEntryData(java.util.zip.ZipEntry ze)Gets the byte [] data for an entry if present.- java.net.URLStreamHandler- getHandler()Gets the URL stream handler.- java.io.InputStream- getInputStream(java.util.zip.ZipEntry ze)Returns an input stream for reading the contents of the specified Zip/Jar file entry.- java.util.jar.JarEntry[]- getJarEntries()Gets all Jar entries if the Jar file is loaded into memory.- java.util.jar.JarEntry- getJarEntry(java.lang.String name)Returns the- JarEntryfor the given entry name or- nullif not found.- java.io.File- getJarFile()Gets the file of the Jar file.- java.util.jar.Manifest- getManifest()Returns the Jar file manifest, or- nullif none.- java.lang.String- getName()Returns the path name of the Zip/Jar file.- java.net.URL- getURL()Gets the MemoryJar URL to be used with e.g.- java.net.URL- getURL(java.lang.String path)Gets the MemoryJar URL to be used with e.g.- java.net.URL- getURL(java.util.zip.ZipEntry entry)Gets the MemoryJar URL to be used with e.g.- default boolean- hasChanged()Checks if the Jar file has changed since last call to this method, i.e.- long- lastModified()Returns the time that the file denoted by this abstract pathname was last modified.- java.util.stream.Stream<java.util.jar.JarEntry>- stream()Returns a stream of Jar entries.
 
- Method Detail- getName- java.lang.String getName() Returns the path name of the Zip/Jar file.- Returns:
- the path name of the Zip/Jar file.
 
 - getJarFile- java.io.File getJarFile() Gets the file of the Jar file.- Returns:
- The Jar Fileused to load the Jar file, ornullfor a memory Jar as there is no validFilerepresentation for it.
 
 - lastModified- long lastModified() Returns the time that the file denoted by this abstract pathname was last modified.- If it's a memory Jar file, this is provided when creating the memory Jar file. - Where it is required to distinguish an I/O exception from the case where - 0Lis returned, or where several attributes of the same file are required at the same time, or where the time of last access or the creation time are required, then the- Files.readAttributesmethod may be used.- Returns:
- A longvalue representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or0Lif the file does not exist or if an I/O error occurs
- Throws:
- java.lang.SecurityException- If a security manager exists and its- SecurityManager.checkRead(java.lang.String)
 
 - hasChanged- default boolean hasChanged() Checks if the Jar file has changed since last call to this method, i.e. this means that the new last modified time and file size is saved.- Returns:
- true if the file has changed in size or last modified time, false otherwise.
 
 - getManifest- java.util.jar.Manifest getManifest() throws java.io.IOExceptionReturns the Jar file manifest, or- nullif none.- Returns:
- the Jar file manifest, or nullif none
- Throws:
- java.lang.IllegalStateException- May be thrown if the Jar file has been closed.
- java.io.IOException- If an I/O error has occurred.
 
 - entries- java.util.Enumeration<java.util.jar.JarEntry> entries() Returns an enumeration of the Jar file entries.- Returns:
- An enumeration of the JarEntry's.
 
 - stream- java.util.stream.Stream<java.util.jar.JarEntry> stream() Returns a stream of Jar entries.- Returns:
- an ordered, distinct, immutable and non-null stream of the Jar file entries.
 
 - getEntry- java.util.zip.ZipEntry getEntry(java.lang.String name) Returns the zip file entry for the specified name, or null if not found.- Parameters:
- name- The name of the entry.
- Returns:
- The Zip file entry, or null if not found.
- Throws:
- java.lang.IllegalStateException- If the Zip file has been closed.
 
 - getJarEntry- java.util.jar.JarEntry getJarEntry(java.lang.String name) Returns the- JarEntryfor the given entry name or- nullif not found.- Parameters:
- name- The Jar file entry name.
- Returns:
- The JarEntryfor the given entry name ornullif not found.
- Throws:
- java.lang.IllegalStateException- May be thrown if the Jar file has been closed.
- See Also:
- JarEntry
 
 - getInputStream- java.io.InputStream getInputStream(java.util.zip.ZipEntry ze) throws java.io.IOExceptionReturns an input stream for reading the contents of the specified Zip/Jar file entry.- Parameters:
- ze- The Zip or Jar file entry.
- Returns:
- An input stream for reading the contents of the specified Zip/Jar file entry.
- Throws:
- java.util.zip.ZipException- If a Zip/Jar file format error has occurred.
- java.io.IOException- If an I/O error has occurred.
- java.lang.SecurityException- If any of the Jar file entries are incorrectly signed.
- java.lang.IllegalStateException- May be thrown if the Jar file has been closed.
 
 - getURL- java.net.URL getURL() Gets the MemoryJar URL to be used with e.g. a class loader.- Returns:
- An URL with the stream handler initialized to this Jar file.
 
 - getURL- java.net.URL getURL(java.util.zip.ZipEntry entry) Gets the MemoryJar URL to be used with e.g. a class loader.- Parameters:
- entry- The Jar entry.
- Returns:
- An URL with the stream handler initialized to this Jar file.
 
 - getURL- java.net.URL getURL(java.lang.String path) Gets the MemoryJar URL to be used with e.g. a class loader.- Parameters:
- path- A path specification.
- Returns:
- An URL with the stream handler initialized to this Jar file.
 
 - getHandler- java.net.URLStreamHandler getHandler() Gets the URL stream handler.- Returns:
- The URL stream handler.
 
 - getEntryData- byte[] getEntryData(java.lang.String name) Gets the byte [] data for an entry if present.- Parameters:
- name- the name of the entry.
- Returns:
- the byte array or null if not found.
 
 - getEntryData- byte[] getEntryData(java.util.zip.ZipEntry ze) Gets the byte [] data for an entry if present.- Parameters:
- ze- the name of the entry.
- Returns:
- the byte array or null if not found.
 
 - getJarEntries- java.util.jar.JarEntry[] getJarEntries() Gets all Jar entries if the Jar file is loaded into memory.- Returns:
- All the entries as a new array.
 
 - close- void close() throws java.io.IOExceptionCloses the Jar file.- Closing this Jar file will close all of the input streams previously returned by invocations of the - getInputStreammethod.- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- java.io.Closeable
- Throws:
- java.io.IOException- if an I/O error has occurred.