ZipUtils
Utilities to zip and unzip data.
API
ZipUtils.java
class ZipUtils {
Stream<ZipEntryDataSource> streamZipEntries(DataSource zippedSource, ZipOptions zipOptions) (1)
Stream<ZipEntryDataSource> streamZipEntries(DataSource zippedSource) (2)
Optional<ZipEntryDataSource> firstZipEntry(DataSource zippedSource, ZipOptions zipOptions) (3)
Optional<ZipEntryDataSource> firstZipEntry(DataSource zippedSource) (4)
byte[] zipToBytes(Stream<ZipEntryDataSource> entryStream)
void writeTo(Stream<ZipEntryDataSource> entryStream, DataSink dataSink)
EntryBuilder zipEntryBuilder() (5)
}
1 | streamZipEntries(DataSource, ZipOptions)
Returns a Stream of ZipEntryDataSource , buffered in memory, which allows consumption even after the underlying zipped DataSource was closed. |
2 | streamZipEntries(DataSource)
Shortcut for streamZipEntries(zippedSource, ZipOptions.builder().build()) |
3 | firstZipEntry(DataSource, ZipOptions)
Optionally the first zip-entry as ZipEntryDataSource , based on whether an entry exists. |
4 | firstZipEntry(DataSource)
Shortcut for firstZipEntry(zippedSource, ZipOptions.builder().build()) |
5 | zipEntryBuilder()
typical example: |
Members
streamZipEntries(DataSource, ZipOptions)
Returns a Stream of ZipEntryDataSource , buffered in memory, which allows consumption even after the underlying zipped DataSource was closed.
streamZipEntries(DataSource)
Shortcut for streamZipEntries(zippedSource, ZipOptions.builder().build())
firstZipEntry(DataSource, ZipOptions)
Optionally the first zip-entry as ZipEntryDataSource , based on whether an entry exists.
zipEntryBuilder()
typical example:
_var builder = ZipUtils.zipEntryBuilder(); for (Map.Entry entry : schemaMap.entrySet()) { var namespaceUri = entry.getKey(); var schemaText = entry.getValue(); builder.addAsUtf8(zipEntryNameFor(namespaceUri), schemaText);_ return Blob.of(fileName, CommonMimeType.ZIP, builder.toBytes()); }