0

I'm working on a java code where it takes a URI as a parameter, but I'm not quite sure what the URI type data looks like. So far, I've tried these things to try get it working:

  • Passing through normal URL in the parameter with&without speechmarks
  • Trying to declare a variable above, which would have parsed a string URL to a URI
  • Copy & pasting trial and error of different SOF answers I found

Can someone post examples of what type of parameters I may pass from this code below? Or how to solve this problem?

private List<SearchExtract> extractFrom(URI uri) throws IOException {
    Document doc = Jsoup.parse(uri.toURL(), 5000);
    Elements select = doc.select(".rc");
    return Collections.singletonList(new SearchExtract(URI.create(""), ""));
}

Sorry if I was quite vague with the problem, I'm confused myself what to do.

1 Answers1

0

I think understanding what URLs, URIs and URNs might help.

What is the difference between a URI, a URL and a URN?

My networking is a bit rusty but I think a URI would be different for everyone depending on what their IP address is. Basically when you make a request on a URL (a specific network location) you call on a URI which is basically the map on how to reach that location.

Taken from http://www.w3.org/TR/uri-clarification/

1.1 Classical View

For example, "http:" was a URL scheme, and "isbn:" would (someday) be a URN scheme. Any new scheme would be cast into one or the other of these two classes.

1.2 Contemporary View

Web-identifer schemes are in general URI schemes; a given URI scheme may define subspaces. Thus "http:" is a URI scheme. "urn:" is also a URI scheme; it defines subspaces, called "namespaces". For example, the set of URNs of the form "urn:isbn:n-nn-nnnnnn-n" is a URN namespace. ("isbn" is an URN namespace identifier. It is not a "URN scheme" nor a "URI scheme").

I may be wrong, but a URI is not always the same for everyone.

Community
  • 1
  • 1
Crayon
  • 39
  • 6