InputStream字节流转为byte[]

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

inputStream = socket.getInputStream();
bufferedInputStream =new BufferedInputStream(inputStream);
byteArrayOutputStream=new ByteArrayOutputStream();
byte[] buffer=null;
int len=0;
byte []buf=new byte[2048];
while((len=bufferedInputStream.read(buf))!=-1){
	byteArrayOutputStream.write(buf, 0, len);
}
byteArrayOutputStream.flush();
buffer=byteArrayOutputStream.toByteArray();

 

转载于:https://my.oschina.net/u/3391025/blog/2966723

你可能感兴趣的:(InputStream字节流转为byte[])