code: private static URL getUrlValueFromRow(QuerySolution resultRow, String variableName) {
  
          // Check the input and exit immediately if null
          if (resultRow == null) {
              return null;
          }
          URL result = null;
          Resource res = resultRow.getResource(variableName);
  
          // Ignore and track services that are blank nodes
          if (res.isAnon()) {
              log.warn("Blank node found and ignored " + res.toString());
          } else if (res.isURIResource()) {
              try {
                  result = new URL(res.getURI());
              } catch (MalformedURLException e) {
                  log.error("Malformed URL for node", e);
              } catch (ClassCastException e) {
                  log.error("The node is not a URI", e);
              }
          }
  
          return result;
      }
docs: Given a query result from a SPARQL query, obtain the given variable value
  as a URL
  
  @param resultRow    the result from a SPARQL query
  @param variableName the name of the variable to obtain
  @return the value or null if it could not be obtained