All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.dongliu.apk.parser.utils.Inputs Maven / Gradle / Ivy

There is a newer version: 2.6.6
Show newest version
package net.dongliu.apk.parser.utils;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class Inputs {

    public static byte[] readAll(InputStream in) throws IOException {
        byte[] buf = new byte[1024 * 8];
        try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
            int len;
            while ((len = in.read(buf)) != -1) {
                bos.write(buf, 0, len);
            }
            return bos.toByteArray();
        }
    }

    public static byte[] readAllAndClose(InputStream in) throws IOException {
        try {
            return readAll(in);
        } finally {
            in.close();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy