private static byte[] toByteArray(InputStream in) throws IOException {
        try {
            byte[] buf = new byte[1024 * 8];
            ByteArrayOutputStream bos = null;
            try {
                bos = new ByteArrayOutputStream();
                int len;
                while ((len = in.read(buf)) != -1) {
                    bos.write(buf, 0, len);
                }
                return bos.toByteArray();
            } finally {
                if (bos != null) {
                    bos.close();
                }
            }
        } finally {
            if (in != null) {
                in.close();
            }
        }
    }
ApkParser and result holder.
This class is not thread-safe.

@author dongliu
replugin-host-library/replugin-host-lib/src/main/java/com/qihoo360/replugin/ext/parser/ApkParser.java