code: public static byte[] readEntityBytes(InputStream in) {
  		byte[] jsonEntity = null;
  		try {
  			if (in != null && in.available() > 0) {
  				ByteArrayOutputStream baos = new ByteArrayOutputStream();
  				byte[] buf = new byte[1024];
  				int length;
  				while ((length = in.read(buf)) > 0) {
  					baos.write(buf, 0, length);
  				}
  				jsonEntity = baos.toByteArray();
  			} else {
  				jsonEntity = new byte[0];
  			}
  		} catch (IOException ex) {
  			logger.error(null, ex);
  		} finally {
  			try {
  				if (in != null) {
  					in.close();
  				}
  			} catch (IOException ex) {
  				logger.error(null, ex);
  			}
  		}
  		return jsonEntity;
  	}
docs: Reads the bytes from an InputStream.
  @param in an InputStream
  @return byte[]