jdk中有没有什么工具直接类可以将InputStream转换成byte数组?
------解决方案--------------------
try{
InputStream is;//你的输入流
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int bytesRead = 0;
byte[] buffer = new byte[128];
while((bytesRead = is.read(buffer,0,buffer.length)) != -1){
baos.write(buffer, 0, bytesRead);
}
byte[] temp = baos.toByteArray();
}catch(Exception e){
e.printStackTrace();
}
------解决方案--------------------
int length =is.available();
byte[] bs =new byte[length];
is.read(bs);
bs就是了.