public class MemoryJarFile 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
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the ZIP file.
|
static MemoryJarFile |
createJarFile(File file,
boolean verify,
boolean winStyle,
MemoryJarFileDecrypter streamDecrypter,
MemoryJarFileDecrypter entryDecrypter)
Creates a memory Jar file.
|
static MemoryJarFile |
createJarFile(InputStream in,
boolean verify,
boolean winStyle,
MemoryJarFileDecrypter streamDecrypter,
MemoryJarFileDecrypter entryDecrypter,
long lastModified)
Creates a memory Jar file.
|
static MemoryJarFile |
createJarFile(JarInputStream jin,
boolean winStyle,
long lastModified)
Creates a memory Jar file.
|
static MemoryJarFile |
createJarFile(JarInputStream jin,
boolean winStyle,
MemoryJarFileDecrypter decrypter,
long lastModified)
Creates a memory Jar file.
|
static MemoryJarFile |
createJarFile(JarInputStream jin,
long lastModified)
Creates a memory Jar file.
|
static MemoryJarFile |
createJarFile(String fileName,
boolean verify,
boolean winStyle,
MemoryJarFileDecrypter streamDecrypter,
MemoryJarFileDecrypter entryDecrypter)
Creates a memory Jar file.
|
Enumeration<JarEntry> |
entries()
Returns an enumeration of the Jar file entries.
|
byte[] |
getByteArray(ZipEntry ze)
Returns the byte array of the contents of the specified zip file entry.
|
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.
|
Manifest |
getManifest()
Returns the Jar file manifest, or
null if none. |
String |
getName()
Gets the name of the Jar file.
|
URL |
getURL()
Gets the MemoryJar URL to be used with e.g.
|
URL |
getURL(String path)
Gets the MemoryJar URL to be used with e.g.
|
URL |
getURL(ZipEntry entry)
Gets the MemoryJar URL to be used with e.g.
|
long |
lastModified()
Returns the time that the file denoted by this abstract pathname was
last modified.
|
void |
setName(String name)
Sets the name of the Jar file.
|
int |
size()
Returns the number of entries in the Jar file.
|
Stream<JarEntry> |
stream()
Returns a stream of Jar entries.
|
finalize, getComment
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getJarManifestEntry, hasChanged
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 static MemoryJarFile createJarFile(JarInputStream jin, long lastModified) throws IOException
jin
- the Jar input stream.lastModified
- time for last file modification, -1L for when the first empty Jar was created.IOException
- for file failures.public static MemoryJarFile createJarFile(JarInputStream jin, boolean winStyle, long lastModified) throws IOException
jin
- the Jar input stream.winStyle
- if true, the entries are case insensitive and backslash can be used with forward slash as well.lastModified
- time for last file modification, -1L for when the first empty Jar was created.IOException
- for file failures.public static MemoryJarFile createJarFile(JarInputStream jin, boolean winStyle, MemoryJarFileDecrypter decrypter, long lastModified) throws IOException
jin
- the Jar input stream.winStyle
- if true, the entries are case insensitive and backslash can be used with forward slash as well.decrypter
- an instance of a class implementing the MemoryJarFileDecrypter interface to provide
decryption of an entry.lastModified
- time for last file modification, -1L for when the first empty Jar was created.IOException
- for file failures.public static MemoryJarFile createJarFile(InputStream in, boolean verify, boolean winStyle, MemoryJarFileDecrypter streamDecrypter, MemoryJarFileDecrypter entryDecrypter, long lastModified) throws IOException
in
- an input stream.verify
- set to true to verify the Jar file for correctness.winStyle
- if true, the entries are case insensitive and backslash can be used with forward slash as well.streamDecrypter
- an instance of a class implementing the MemoryJarFileDecrypter interface to provide
decryption of the entire input stream data, set to null
for no decryption.entryDecrypter
- an instance of a class implementing the MemoryJarFileDecrypter interface to provide
decryption of an entry, set to null
for no decryption.lastModified
- time for last file modification, -1L for when the first empty Jar was created.IOException
- for file failures.public static MemoryJarFile createJarFile(String fileName, boolean verify, boolean winStyle, MemoryJarFileDecrypter streamDecrypter, MemoryJarFileDecrypter entryDecrypter) throws IOException
fileName
- the file name of Jar file to read.verify
- set to true to verify the Jar file for correctness.winStyle
- if true, the entries are case insensitive and backslash can be used with forward slash as well.streamDecrypter
- an instance of a class implementing the MemoryJarFileDecrypter interface to provide
decryption of the entire input stream data, set to null
for no decryption.entryDecrypter
- an instance of a class implementing the MemoryJarFileDecrypter interface to provide
decryption of an entry, set to null
for no decryption.IOException
- for file failures.public static MemoryJarFile createJarFile(File file, boolean verify, boolean winStyle, MemoryJarFileDecrypter streamDecrypter, MemoryJarFileDecrypter entryDecrypter) throws IOException
file
- the Jar File instance to read.verify
- set to true to verify the Jar file for correctness.winStyle
- if true, the entries are case insensitive and backslash can be used with forward slash as well.streamDecrypter
- an instance of a class implementing the MemoryJarFileDecrypter interface to provide
decryption of the entire input stream data, set to null
for no decryption.entryDecrypter
- an instance of a class implementing the MemoryJarFileDecrypter interface to provide
decryption of an entry, set to null
for no decryption.IOException
- for file failures.public File getJarFile()
getJarFile
in interface IJarFile
null
as there is no File
representation for a memory Jar.public long lastModified()
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 occurspublic Handler getHandler()
getHandler
in interface IJarFile
public URL getURL()
public URL getURL(ZipEntry entry)
public Enumeration<JarEntry> entries()
public JarEntry[] getJarEntries()
getJarEntries
in interface IJarFile
public InputStream getInputStream(ZipEntry ze) throws FileNotFoundException
getInputStream
in interface IJarFile
getInputStream
in class JarFile
ze
- The Zip or Jar file entry.FileNotFoundException
- if the entry isn't found.public byte[] getByteArray(ZipEntry ze) throws FileNotFoundException
FileNotFoundException
- if the entry isn't found.public JarEntry getJarEntry(String name)
getJarEntry
in interface IJarFile
getJarEntry
in class JarFile
name
- name of the Jar entry, 'winStyle' parameter applies, i.e. '\' is translated
to '/' and the name check is done case insensitive.JarEntry
public int size()
public Manifest getManifest()
null
if none.getManifest
in interface IJarFile
getManifest
in class JarFile
null
if none.public String getName()
setName
,
the "real" temporary Jar file name from the temporary directory is returned.public void setName(String name)
getName
method will return that name
(if non-null), or the "real" temporary Jar file name from the temporary directory if the
name
parameter is null
.name
- the name of the Jar file or null to reset it to the "real" temporary Jar file.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 ZIP 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 occurredPhantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.