Revert "Revert "move dexing to WorkerExecutor."" am: 7d395b86cc
am: e605e71644

Change-Id: I797800ec667249e80474a2fedc80781ae349b24d
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.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 @@
     }
 
     /**
+     * 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