use of com.android.tools.build.bundletool.io.ZipReader.EntryNotFoundException in project bundletool by google.
the class ZipReader method getUncompressedPayload.
/**
* Returns an {@link InputStream} of the uncompressed payload of a zip entry.
*/
@MustBeClosed
public InputStream getUncompressedPayload(String entryName) {
Entry entry = getEntry(entryName).orElseThrow(() -> new EntryNotFoundException(zipMap.getFile(), entryName));
InputStream entryPayload = getEntryPayload(entry);
if (!entry.isCompressed()) {
return entryPayload;
}
// nowrap = gzip compatible
Inflater inflater = new Inflater(/* nowrap= */
true);
return new InflaterInputStream(entryPayload, inflater, BUFFER_SIZE_BYTES);
}
use of com.android.tools.build.bundletool.io.ZipReader.EntryNotFoundException in project bundletool by google.
the class ZipReader method transferTo.
/**
* Copies the bytes of the payload of a zip entry to the given {@link ZipWriter}.
*
* <p>The copy happens using {@link FileChannel#transferTo} which takes advantage of filesystem
* cache, making it a very I/O efficient way to copy data across files.
*/
public void transferTo(ZipWriter zipWriter, String entryName) {
Entry entry = getEntry(entryName).orElseThrow(() -> new EntryNotFoundException(zipMap.getFile(), entryName));
Location payloadLocation = entry.getPayloadLocation();
try {
zipWriter.transferFrom(fileChannel, payloadLocation.first, payloadLocation.size());
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
Aggregations