Reads the contents of the stream into a byte array. data is returned as a byte array. An IOException is thrown if any of the underlying IO calls fail.