public class Jar extends Object
| Constructor and Description |
|---|
Jar()
Creates a new, empty, JAR
|
Jar(File jar)
Reads in the JAR from the given
File. |
Jar(InputStream jar)
Reads in the JAR from the given
InputStream. |
Jar(JarFile jar)
Reads in the JAR from the given
JarFile. |
Jar(Path jar)
Reads in the JAR from the given
Path. |
Jar(String jar)
Reads in the JAR from the given path.
|
| Modifier and Type | Method and Description |
|---|---|
Jar |
addEntry(Path path,
InputStream is)
Adds an entry to this JAR.
|
Jar |
addEntry(Path path,
Path file)
Adds an entry to this JAR.
|
Jar |
addEntry(Path path,
String file)
Adds an entry to this JAR.
|
Jar |
addEntry(String path,
File file)
Adds an entry to this JAR.
|
Jar |
addEntry(String path,
InputStream is)
Adds an entry to this JAR.
|
Jar |
addEntry(String path,
String file)
Adds an entry to this JAR.
|
String |
getAttribute(String name)
Returns an attribute's value from this JAR's manifest's main section.
|
String |
getAttribute(String section,
String name)
Returns an attribute's value from a non-main section of this JAR's manifest.
|
List<String> |
getListAttribute(String name)
Returns an attribute's list value from this JAR's manifest's main section.
|
List<String> |
getListAttribute(String section,
String name)
Returns an attribute's list value from a non-main section of this JAR's manifest.
|
Manifest |
getManifest()
Returns the manifest of this JAR.
|
Jar |
setAttribute(String name,
String value)
Sets an attribute in the main section of the manifest.
|
Jar |
setAttribute(String section,
String name,
String value) |
Jar |
setListAttribute(String name,
List<String> values)
Sets an attribute in the main section of the manifest to a list.
|
Jar |
setListAttribute(String section,
String name,
List<String> values)
Sets an attribute in a non-main section of the manifest to a list.
|
static InputStream |
toInputStream(String str,
Charset charset)
Turns a
String into an InputStream containing the string's encoded characters. |
File |
write(File file)
Writes this JAR to a file.
|
Path |
write(Path path)
Writes this JAR to a file.
|
void |
write(String file)
Writes this JAR to a file.
|
<T extends OutputStream> |
write(T os)
Writes this JAR to an output stream.
|
public Jar()
public Jar(InputStream jar) throws IOException
InputStream.
Modifications will not be made to the original JAR file, but to a new copy, which is then written with write().IOExceptionpublic Jar(JarFile jar) throws IOException
JarFile.
Modifications will not be made to the original JAR file, but to a new copy, which is then written with write().IOExceptionpublic Jar(Path jar) throws IOException
Path.
Modifications will not be made to the original JAR file, but to a new copy, which is then written with write().IOExceptionpublic Jar(File jar) throws IOException
File.
Modifications will not be made to the original JAR file, but to a new copy, which is then written with write().IOExceptionpublic Jar(String jar) throws IOException
write().IOExceptionpublic Manifest getManifest()
addEntry().public Jar setAttribute(String name, String value)
name - the attribute's namevalue - the attribute's valuethisIllegalStateException - if entries have been added or the JAR has been written prior to calling this methods.public Jar setListAttribute(String name, List<String> values)
name - the attribute's namevalues - the attribute's valuethisIllegalStateException - if entries have been added or the JAR has been written prior to calling this methods.public Jar setListAttribute(String section, String name, List<String> values)
section - the section's namename - the attribute's namevalues - the attribute's valuethisIllegalStateException - if entries have been added or the JAR has been written prior to calling this methods.public String getAttribute(String name)
name - the attribute's namepublic String getAttribute(String section, String name)
section - the manifest's sectionname - the attribute's namepublic List<String> getListAttribute(String name)
name - the attribute's namepublic List<String> getListAttribute(String section, String name)
section - the manifest's sectionname - the attribute's namepublic Jar addEntry(String path, InputStream is) throws IOException
path - the entry's path within the JARis - the entry's contentthisIOExceptionpublic Jar addEntry(Path path, InputStream is) throws IOException
path - the entry's path within the JARis - the entry's contentthisIOExceptionpublic Jar addEntry(Path path, Path file) throws IOException
path - the entry's path within the JARfile - the file to add as an entrythisIOExceptionpublic Jar addEntry(Path path, String file) throws IOException
path - the entry's path within the JARfile - the path of the file to add as an entrythisIOExceptionpublic Jar addEntry(String path, File file) throws IOException
path - the entry's path within the JARfile - the file to add as an entrythisIOExceptionpublic Jar addEntry(String path, String file) throws IOException
path - the entry's path within the JARfile - the path of the file to add as an entrythisIOExceptionpublic <T extends OutputStream> T write(T os) throws IOException
IOExceptionpublic File write(File file) throws IOException
IOExceptionpublic Path write(Path path) throws IOException
IOExceptionpublic void write(String file) throws IOException
IOExceptionpublic static InputStream toInputStream(String str, Charset charset)
String into an InputStream containing the string's encoded characters.str - the stringcharset - the Charset to use when encoding the string.InputStream containing the string's encoded characters.