public static byte[] readData(final InputStream input) throws IOException {
  final byte[] inputBuffer=new byte[BUFFER_LENGTH];
  final ByteArrayOutputStream byteOutput=new ByteArrayOutputStream(BUFFER_LENGTH);
  int bytesRead;
  while ((bytesRead=input.read(inputBuffer)) != -1) {
    byteOutput.write(inputBuffer,0,bytesRead);
  }
  final byte[] r=byteOutput.toByteArray();
  byteOutput.close();
  return r;
}

public static byte [ ] readData ( final InputStream input ) throws IOException { final byte [ ] inputBuffer = new byte [ BUFFER_LENGTH ] ; final ByteArrayOutputStream byteOutput = new ByteArrayOutputStream ( BUFFER_LENGTH ) ; int bytesRead ; while ( ( bytesRead = input . read ( inputBuffer ) ) != - 1 ) { byteOutput . write ( inputBuffer , 0 , bytesRead ) ; } final byte [ ] r = byteOutput . toByteArray ( ) ; byteOutput . close ( ) ; return r ; }
reads all the data from the supplied inputstream into a byte array .
