code: private InputStream runSparqlQuery(String query) throws IOException {
  		try {
  			String queryString = "query=" + URLEncoder.encode(query, "UTF-8")
  					+ "&format=json";
  			URL url = new URL("https://query.wikidata.org/sparql?"
  					+ queryString);
  			HttpURLConnection connection = (HttpURLConnection) url
  					.openConnection();
  			connection.setRequestMethod("GET");
  
  			return connection.getInputStream();
  		} catch (UnsupportedEncodingException | MalformedURLException e) {
  			throw new RuntimeException(e.getMessage(), e);
  		}
  	}
docs: Executes a given SPARQL query and returns a stream with the result in
  JSON format.
  
  @param query
  @return
  @throws IOException