根據輸入流獲得字節數組

public static byte[] read(InputStream in) throws IOException{
  byte[] arr=new byte[1024];
  ByteArrayOutputStream out=new ByteArrayOutputStream();
  int len=0;
  while((len=in.read(arr))!=-1){
   out.write(arr, 0, len);
  }
  out.close();
  return out.toByteArray();
 }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章