public class ZipUtil extends Object
Utilities for mucking with zip files.
| Constructor and Description |
|---|
ZipUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
modify(InputStream input,
OutputStream output,
Map<String,InputStream> toModify,
Set<String> toOmit)
Modifies only the specified entries in a zip file.
|
static String |
read(File input,
String toRead)
Reads the given entry from the zip.
|
static void |
read(File input,
String toRead,
Throwing.Specific.Consumer<InputStream,IOException> reader)
Reads the given entry from the zip.
|
static void |
zip(File input,
String pathWithinArchive,
File output)
Creates a single-entry zip file.
|
public static void read(File input, String toRead, Throwing.Specific.Consumer<InputStream,IOException> reader) throws IOException
Reads the given entry from the zip.
input - a zip filetoRead - a path within that zip filereader - will be called with an InputStream containing the contents of that entry in the zip fileIOExceptionpublic static String read(File input, String toRead) throws IOException
Reads the given entry from the zip.
input - a zip filetoRead - a path within that zip fileIOExceptionpublic static void modify(InputStream input, OutputStream output, Map<String,InputStream> toModify, Set<String> toOmit) throws IOException
Modifies only the specified entries in a zip file.
input - an input stream from a zip fileoutput - an output stream to a zip filetoModify - a map from path to an input stream for the entries you’d like to changetoOmit - a set of entries you’d like to leave out of the zipIOExceptionpublic static void zip(File input, String pathWithinArchive, File output) throws IOException
Creates a single-entry zip file.
input - an uncompressed filepathWithinArchive - the path within the archiveoutput - the new zip file it will be compressed intoIOException