Java流

1.输入流转字节数组

public static byte[] inputStream2byte(InputStream inputStream) throws IOException {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        byte[] buff = new byte[100];
        int n = 0;
        while ((n = inputStream.read(buff, 0, 100)) > 0) {
            byteArrayOutputStream.write(buff, 0, n);
        }
        return byteArrayOutputStream.toByteArray();
    }

 

posted @ 2022-06-10 17:12  N神3  阅读(33)  评论(0编辑  收藏  举报