diff options
author | Ivan Gavrilovic <gavra@google.com> | 2017-07-06 12:30:51 +0100 |
---|---|---|
committer | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-07-06 16:23:57 +0000 |
commit | 7d395b86ccfae70cceb793fde97dc8ec11f33b52 (patch) | |
tree | b61cf9789bd2990b23485a4b75510ff8468bf6af /src | |
parent | 235e51c114349ded1a562f1158ea04e6cab73766 (diff) | |
download | apkzlib-7d395b86ccfae70cceb793fde97dc8ec11f33b52.tar.gz |
Revert "Revert "move dexing to WorkerExecutor.""
Original change: Icc60a18fd6850ab10bddb297fe7754f81f53809c
This reverts commit 493e54f4aae54dec2e143a6835d260ce97c479ec.
Test: existing
Change-Id: I64864622e4c0d21fef4aee8ca8bfd313b0a49b38
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/android/apkzlib/zip/StoredEntry.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/com/android/apkzlib/zip/StoredEntry.java b/src/main/java/com/android/apkzlib/zip/StoredEntry.java index 664734e..5693fce 100644 --- a/src/main/java/com/android/apkzlib/zip/StoredEntry.java +++ b/src/main/java/com/android/apkzlib/zip/StoredEntry.java @@ -24,6 +24,7 @@ import com.google.common.base.Verify; import com.google.common.io.ByteSource; import com.google.common.io.ByteStreams; import com.google.common.primitives.Ints; +import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; @@ -347,6 +348,23 @@ public class StoredEntry { } /** + * Obtains the contents of the file in an existing buffer. + * + * @param bytes buffer to read the file contents in. + * @return the number of bytes read + * @throws IOException failed to read the file. + */ + public int read(byte[] bytes) throws IOException { + if (bytes.length < getCentralDirectoryHeader().getUncompressedSize()) { + throw new RuntimeException( + "Buffer to small while reading {}" + getCentralDirectoryHeader().getName()); + } + try (InputStream is = new BufferedInputStream(open())) { + return ByteStreams.read(is, bytes, 0, bytes.length); + } + } + + /** * Obtains the type of entry. * * @return the type of entry |