InputStream转byte数组

以便日常使用input

public static byte[] read(InputStream inputStream) throws IOException {
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] buffer = new byte[1024];
            int num = 0;
            while ((num = inputStream.read(buffer)) != -1) {
                baos.write(buffer, 0, num);
            }
            baos.flush();
            return baos.toByteArray();
        }
        finally {
            if (inputStream != null) {
                inputStream.close();
            }
        }
    }it