public class NpJarFile extends JarFile implements IJarFile
Please note that this class currently only supports file items smaller than 2 GB, i.e. a 31 bit long positive integer value.
Modifier and Type | Field and Description |
---|---|
static int |
CENATT |
static int |
CENATX |
static int |
CENCOM |
static int |
CENCRC |
static int |
CENDSK |
static int |
CENEXT |
static int |
CENFLG |
static int |
CENHDR |
static int |
CENHOW |
static int |
CENLEN |
static int |
CENNAM |
static int |
CENOFF |
static long |
CENSIG |
static int |
CENSIZ |
static int |
CENTIM |
static int |
CENVEM |
static int |
CENVER |
static int |
ENDCOM |
static int |
ENDHDR |
static int |
ENDOFF |
static long |
ENDSIG |
static int |
ENDSIZ |
static int |
ENDSUB |
static int |
ENDTOT |
static int |
EXTCRC |
static int |
EXTHDR |
static int |
EXTLEN |
static long |
EXTSIG |
static int |
EXTSIZ |
static int |
LOCCRC |
static int |
LOCEXT |
static int |
LOCFLG |
static int |
LOCHDR |
static int |
LOCHOW |
static int |
LOCLEN |
static int |
LOCNAM |
static long |
LOCSIG |
static int |
LOCSIZ |
static int |
LOCTIM |
static int |
LOCVER |
MANIFEST_NAME
OPEN_DELETE, OPEN_READ
MANIFEST_ENTRY
Constructor and Description |
---|
NpJarFile(File file)
Loads or opens the JAR file "inMemory", without "winStyle", but with "verify".
|
NpJarFile(File file,
boolean inMemory,
boolean winStyle,
boolean verify)
Loads or opens the JAR file.
|
NpJarFile(String name)
Loads or opens the JAR file "inMemory", without "winStyle", but with "verify".
|
NpJarFile(String name,
boolean inMemory,
boolean winStyle,
boolean verify)
Loads or opens the JAR file.
|
Modifier and Type | Method and Description |
---|---|
static void |
clearLoadedFilesList()
Clears the loaded files list.
|
void |
close()
Closes the Jar file.
|
Enumeration<JarEntry> |
entries()
Returns an enumeration of the Jar file entries.
|
ZipEntry |
getEntry(String name)
Gets the ZIP entry with the specified name.
|
byte[] |
getEntryData(String name)
Gets the byte [] data for an entry if present.
|
byte[] |
getEntryData(ZipEntry ze)
Gets the byte [] data for an entry if present.
|
Handler |
getHandler()
Gets the URL stream handler for the MemoryJarFile.
|
InputStream |
getInputStream(ZipEntry ze)
Returns an input stream for reading the contents of the specified zip file entry.
|
JarEntry[] |
getJarEntries()
Gets all Jar entries if the Jar file is loaded into memory.
|
JarEntry |
getJarEntry(String name)
Gets the JAR entry with the specified name.
|
File |
getJarFile()
Gets the file of the Jar file.
|
static NpJarFile |
getJarFile(File file)
Loads the requested NpJarFile or grabs one from the table of loaded files and reloads
it as required.
|
static NpJarFile |
getJarFile(String fileName)
Loads the requested NpJarFile or grabs one from the table of loaded files and reloads
it as required.
|
Manifest |
getManifest()
Returns the jar file manifest, or
null if none. |
URL |
getURL()
Gets the NpJar URL to be used with e.g.
|
URL |
getURL(String path)
Gets the NpJar URL to be used with e.g.
|
URL |
getURL(ZipEntry entry)
Gets the NpJar URL to be used with e.g.
|
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.
|
int |
size()
Returns the number of entries in the Jar file.
|
Stream<JarEntry> |
stream()
Returns a stream of Jar entries.
|
finalize, getComment, getName
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getJarManifestEntry, getName
public static final long LOCSIG
public static final long EXTSIG
public static final long CENSIG
public static final long ENDSIG
public static final int LOCHDR
public static final int EXTHDR
public static final int CENHDR
public static final int ENDHDR
public static final int LOCVER
public static final int LOCFLG
public static final int LOCHOW
public static final int LOCTIM
public static final int LOCCRC
public static final int LOCSIZ
public static final int LOCLEN
public static final int LOCNAM
public static final int LOCEXT
public static final int EXTCRC
public static final int EXTSIZ
public static final int EXTLEN
public static final int CENVEM
public static final int CENVER
public static final int CENFLG
public static final int CENHOW
public static final int CENTIM
public static final int CENCRC
public static final int CENSIZ
public static final int CENLEN
public static final int CENNAM
public static final int CENEXT
public static final int CENCOM
public static final int CENDSK
public static final int CENATT
public static final int CENATX
public static final int CENOFF
public static final int ENDSUB
public static final int ENDTOT
public static final int ENDSIZ
public static final int ENDOFF
public static final int ENDCOM
public NpJarFile(String name) throws IOException
name
- the file name.IOException
- for file failures.public NpJarFile(File file) throws IOException
file
- the file.IOException
- for file failures.public NpJarFile(String name, boolean inMemory, boolean winStyle, boolean verify) throws IOException
name
- the file name.inMemory
- if true, the entire Jar file is loaded into memory and then closed. Subsequent operations can be
performed as normal.winStyle
- if true, the entries are case insensitive and backslash can be used with forward slash as well.verify
- if the Jar file should be verified.IOException
- for file failures.public NpJarFile(File file, boolean inMemory, boolean winStyle, boolean verify) throws IOException
file
- the file.inMemory
- if true, the entire Jar file is loaded into memory and then closed. Subsequent operations can be
performed as normal.winStyle
- if true, the entries are case insensitive and backslash can be used with forward slash as well.verify
- if the Jar file should be verified.IOException
- for file failures.public static void clearLoadedFilesList()
public static NpJarFile getJarFile(String fileName) throws IOException
IOException
- for file failures.public static NpJarFile getJarFile(File file) throws IOException
IOException
- for file failures.public long lastModified()
Where it is required to distinguish an I/O exception from the case
where 0L
is 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.readAttributes
method may be used.
lastModified
in interface IJarFile
long
value representing the time the file was
last modified, measured in milliseconds since the epoch
(00:00:00 GMT, January 1, 1970), or 0L
if the
file does not exist or if an I/O error occursSecurityException
- If a security manager exists and its SecurityManager.checkRead(java.lang.String)
method denies read access to the filepublic File getJarFile()
getJarFile
in interface IJarFile
public Handler getHandler()
getHandler
in interface IJarFile
public URL getURL()
public boolean hasChanged()
hasChanged
in interface IJarFile
public Enumeration<JarEntry> entries()
public JarEntry[] getJarEntries()
getJarEntries
in interface IJarFile
public InputStream getInputStream(ZipEntry ze) throws IOException
getInputStream
in interface IJarFile
getInputStream
in class JarFile
ze
- The Zip or Jar file entry.ZipException
- if a zip file format error has occurred.IOException
- if an I/O error has occurred.SecurityException
- if any of the jar file entries are incorrectly signed.IllegalStateException
- may be thrown if the jar file has been closed.public JarEntry getJarEntry(String name)
getJarEntry
in interface IJarFile
getJarEntry
in class JarFile
name
- The Jar file entry name.JarEntry
for the given entry name or
null
if not found.JarEntry
public int size()
size
in class ZipFile
IllegalStateException
- if the Jar file has been closed.public Manifest getManifest() throws IOException
null
if none.getManifest
in interface IJarFile
getManifest
in class JarFile
null
if none.IllegalStateException
- may be thrown if the jar file has been closedIOException
- If an I/O error has occurred.public byte[] getEntryData(String name)
getEntryData
in interface IJarFile
name
- the name of the entry.public byte[] getEntryData(ZipEntry ze)
getEntryData
in interface IJarFile
ze
- the name of the entry.public void close() throws IOException
Closing this Jar file will close all of the input streams
previously returned by invocations of the getInputStream
method.
close
in interface IJarFile
close
in interface Closeable
close
in interface AutoCloseable
close
in class ZipFile
IOException
- if an I/O error has occurred.Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.