Search in sources :

Example 1 with Location

use of com.android.zipflinger.Location 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);
    }
}
Also used : Entry(com.android.zipflinger.Entry) EntryNotFoundException(com.android.tools.build.bundletool.io.ZipReader.EntryNotFoundException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Location(com.android.zipflinger.Location)

Aggregations

EntryNotFoundException (com.android.tools.build.bundletool.io.ZipReader.EntryNotFoundException)1 Entry (com.android.zipflinger.Entry)1 Location (com.android.zipflinger.Location)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1