I'm trying to build URI's using the JDK java.net.URI.
I want to append to an absolute URI object, a query (in String). In example:
URI base = new URI("http://example.com/something/more/long");
String queryString = "query=http://local:282/rand&action=aaaa";
URI query = new URI(null, null, null, queryString, null);
URI result = base.resolve(query);
Theory (or what I think) is that resolve should return:
http://example.com/something/more/long?query=http://local:282/rand&action=aaaa
But what I got is:
http://example.com/something/more/?query=http://local:282/rand&action=aaaa
Why #resolve() "eats" the last path? If the new URI (query
) is built as:
URI query = new URI(null, null, base.getPath(), queryString, null);
It works well.