title: How to fix an URIException about an illegal character in query
body: <p>I'm using java.net package to download an xml file from a web service, but I get this error:"Illegal character in query at index 103: <a href="http://.............../current?path=//Controller/Components/Path/DataItems/DataItem[@type=" rel="nofollow noreferrer">http://.............../current?path=//Controller/Components/Path/DataItems/DataItem[@type=</a>"PART_COUNT"]</p>
  
  <p>I've looked for the position. It should be "=".  </p>
  
  <pre><code>import java.io.IOException;
  import java.net.URI;
  import java.net.URISyntaxException;
  import java.net.http.HttpClient;
  import java.net.http.HttpClient.Builder;
  import java.net.http.HttpClient.Version;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.net.http.HttpResponse.BodyHandlers;
  
  
  public class App 
  {
      public static void main( String[] args )
      {
  
  
          HttpClient client = HttpClient
                  .newBuilder()
                  .version(Version.HTTP_2)
                  .build();
  
          Builder builder;
          try {
              builder = (Builder) HttpRequest.newBuilder(new URI("http://............./current?path=//Controller/Components/Path/DataItems/DataItem[@type=\"PART_COUNT\"]"));
              HttpRequest request = ((java.net.http.HttpRequest.Builder) builder).GET().build();
  
  
              HttpResponse httpResponse = client.send(request, BodyHandlers.ofString());
               String body = (String) httpResponse.body();
               System.out.println(body);
  
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          catch (Exception e) {
              System.out.println(e.getMessage());
          }
  
  
      }
  }
  </code></pre>
  
  <p>I expect to download the information from the url in a xml file. Now I'm going to print on screen.</p>
  
  <pre><code>&lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
    &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;/properties&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
    &lt;build&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
        &lt;version&gt;3.7.0&lt;/version&gt;
        &lt;configuration&gt;
          &lt;source&gt;9&lt;/source&gt;
          &lt;target&gt;9&lt;/target&gt;
          &lt;compilerArgument&gt;--add-modules=jdk.incubator.httpclient&lt;/compilerArgument&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
        &lt;version&gt;2.20.1&lt;/version&gt;
        &lt;configuration&gt;
        &lt;argLine&gt;--add-modules=jdk.incubator.httpclient&lt;/argLine&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>