java读取流的操作

 

public static byte[] read(InputStream inStream) throws Exception
 {
  ByteArrayOutputStream outputStream=new ByteArrayOutputStream();//创建缓存将读到的信息放到缓存中


  byte[] buffer=new byte[1024];
  int length=0;
  while((length=inStream.read(buffer))!=-1)
  {
   outputStream.write(buffer, 0, buffer.length);
  }
  inStream.close();
  return outputStream.toByteArray();
 }

posted @ 2014-03-28 18:30  -琥珀川-  阅读(392)  评论(0编辑  收藏  举报