public class ZipMisc extends Object
Utilities for mucking with zip files.
Constructor and Description |
---|
ZipMisc() |
Modifier and Type | Method and Description |
---|---|
static void |
modify(com.diffplug.common.io.ByteSource input,
com.diffplug.common.io.ByteSink output,
Map<String,Function<byte[],byte[]>> toModify,
Predicate<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 |
unzip(File input,
File destinationDir)
Unzips a directory to a folder.
|
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 fileIOException
public 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 fileIOException
public static void modify(com.diffplug.common.io.ByteSource input, com.diffplug.common.io.ByteSink output, Map<String,Function<byte[],byte[]>> toModify, Predicate<String> toOmit) throws IOException
Modifies only the specified entries in a zip file.
input
- a source from a zip fileoutput
- an output 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 zipIOException
public 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
public static void unzip(File input, File destinationDir) throws IOException
Unzips a directory to a folder.
input
- a zip filedestinationDir
- where the zip will be extracted toIOException