public static byte[] readStream(InputStream stream){
  ByteArrayOutputStream rawBuffer=new ByteArrayOutputStream();
  try {
    int nRead;
    byte[] data=new byte[1024 * 16];
    while ((nRead=stream.read(data,0,data.length)) != -1) {
      rawBuffer.write(data,0,nRead);
    }
    rawBuffer.flush();
    rawBuffer.close();
  }
 catch (  IOException e) {
    log.warning("Error reading audio stream: " + e);
  }
  return rawBuffer.toByteArray();
}

public static byte [ ] readStream ( InputStream stream ) { ByteArrayOutputStream rawBuffer = new ByteArrayOutputStream ( ) ; try { int nRead ; byte [ ] data = new byte [ 1024 * 16 ] ; while ( ( nRead = stream . read ( data , 0 , data . length ) ) != - 1 ) { rawBuffer . write ( data , 0 , nRead ) ; } rawBuffer . flush ( ) ; rawBuffer . close ( ) ; } catch ( IOException e ) { log . warning ( "Error reading audio stream: " + e ) ; } return rawBuffer . toByteArray ( ) ; }
reads the input stream and returns the corresponding array of bytes
