public static byte[] getResponseBody(HttpResponse resp) throws IOException {
    if (resp.getEntity() == null) {
      return null;
    }
    InputStream instream = resp.getEntity().getContent();
    if (instream == null) {
      return null;
    }
    try {
      long contentLength = resp.getEntity().getContentLength();
      if (contentLength > Integer.MAX_VALUE) {
        // guard integer cast from overflow
        throw new IOException("Content too large to be buffered: " + contentLength + " bytes");
      }
      if (contentLength > 0) {
        byte[] content = new byte[(int) contentLength];
        ByteStreams.readFully(instream, content);
        return content;
      } else {
        return ByteStreams.toByteArray(instream);
      }
    } finally {
      Closeables.closeQuietly(instream);
    }
  }
Returns the response body of the HTTPResponse, if any, as an array of bytes. If response body
is not available or cannot be read, returns <tt>null</tt> Note: This will cause the entire
response body to be buffered in memory. A malicious server may easily exhaust all the VM
memory. It is strongly recommended, to use getResponseAsStream if the content length of the
response is unknown or reasonably large.
@param resp HttpResponse
@return The response body, null if body is empty
@throws IOException If an I/O (transport) problem occurs while obtaining the response body.
hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java